diff options
Diffstat (limited to 'NET/worlds/network/WorldServer.java')
| -rw-r--r-- | NET/worlds/network/WorldServer.java | 1922 |
1 files changed, 1922 insertions, 0 deletions
diff --git a/NET/worlds/network/WorldServer.java b/NET/worlds/network/WorldServer.java new file mode 100644 index 0000000..02f567d --- /dev/null +++ b/NET/worlds/network/WorldServer.java @@ -0,0 +1,1922 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.console.Main; +/* */ import NET.worlds.console.MainCallback; +/* */ import NET.worlds.console.MainTerminalCallback; +/* */ import NET.worlds.core.Std; +/* */ import NET.worlds.scape.Drone; +/* */ import NET.worlds.scape.WObject; +/* */ import java.io.ByteArrayOutputStream; +/* */ import java.io.EOFException; +/* */ import java.io.IOException; +/* */ import java.io.OutputStream; +/* */ import java.io.PrintStream; +/* */ import java.net.InetAddress; +/* */ import java.net.Socket; +/* */ import java.text.MessageFormat; +/* */ import java.util.Enumeration; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class WorldServer +/* */ implements MainCallback, MainTerminalCallback, NetworkObject +/* */ { +/* */ protected int _serverProtocolVersion; +/* 238 */ protected ServerURL _serverURL = null; +/* 239 */ protected String _clientVersion = Std.getJavaBuildDate(); +/* */ +/* */ protected WSConnecting _connectThread; +/* */ +/* 243 */ protected OutputStream _ostr = null; +/* 244 */ protected Socket _sock = null; +/* 245 */ protected netPacketReader _reader = null; +/* */ +/* */ +/* */ private WaitList _waiters; +/* */ +/* 250 */ protected int _refCnt = 0; +/* 251 */ protected int _tmpRefCnt = 0; +/* 252 */ protected boolean _isMainRegistered = false; +/* 253 */ protected ObjectMgr _objTable = null; +/* 254 */ protected Galaxy _galaxy = null; +/* */ protected SMState _state; +/* 256 */ protected boolean _firstLogon = false; +/* 257 */ protected boolean _requestOffline = false; +/* 258 */ private int _lastAccessTime = 0; +/* */ +/* 260 */ protected int _retriesLeft = 5; +/* 261 */ protected VarErrorException _lastError = null; +/* 262 */ protected int _retryTimeout = 60000; +/* */ +/* 264 */ private int _lastMsgProcCnt = 5; +/* 265 */ protected PropertyList _propList = null; +/* 266 */ protected int _updateTime = 2000; +/* */ Vector<BackupServer> _backupServers; +/* */ String _currentBackupServer; +/* */ private static final int STATE_DEAD = -1; +/* */ protected static final int STATE_PRECONNECTED = 0; +/* */ private static final int STATE_AUTHPROMPT = 1; +/* */ +/* */ protected class BackupServer { +/* 274 */ public BackupServer() { this.hostName = ""; +/* 275 */ this.tries = 0; +/* */ } +/* */ +/* */ public BackupServer(String host) { +/* 279 */ this.hostName = host; +/* 280 */ this.tries = 0; +/* */ } +/* */ +/* */ public String GetHost() { +/* 284 */ return this.hostName; +/* */ } +/* */ +/* */ public void IncTries() +/* */ { +/* 289 */ this.tries += 1; +/* */ } +/* */ +/* */ +/* */ protected String hostName; +/* */ +/* */ protected int tries; +/* */ } +/* */ +/* */ +/* */ private static final int STATE_AUTHREPLY = 2; +/* */ +/* */ protected static final int STATE_INITIALIZING = 3; +/* */ +/* */ private static final int STATE_CONNECTING = 4; +/* */ +/* */ private static final int STATE_XMIT_PROPREQ = 5; +/* */ +/* */ private static final int STATE_RCV_PROPS = 6; +/* */ +/* */ protected static final int STATE_XMIT_SI = 7; +/* */ +/* */ static final int STATE_RCV_SI_ACK = 8; +/* */ +/* */ static final int STATE_XMIT_AI = 9; +/* */ +/* */ static final int STATE_RCV_AI_ACK = 10; +/* */ +/* */ static final int STATE_XMIT_PROPS = 11; +/* */ +/* */ static final int STATE_MAINLOOP = 12; +/* */ +/* */ private static final int STATE_XMIT_AE = 13; +/* */ +/* */ private static final int STATE_RCV_AE_ACK = 14; +/* */ private static final int STATE_XMIT_SE = 15; +/* */ static final int STATE_RCV_SE_ACK = 16; +/* */ static final int STATE_DETACHING = 17; +/* */ static final int STATE_DISCONNECTED = 18; +/* */ static final int STATE_SLEEPING = 19; +/* */ protected WorldServer() +/* */ { +/* 331 */ this._serverProtocolVersion = 24; +/* */ +/* 333 */ this._state = new SMState(this, 0); +/* 334 */ this._currentBackupServer = null; +/* 335 */ this._backupServers = new Vector(); +/* */ } +/* */ +/* */ +/* */ +/* */ public void regShortID(int shortObjID, String longObjID) +/* */ { +/* 342 */ assert (shortObjID < 253); +/* 343 */ this._objTable.regShortID(shortObjID, longObjID); +/* */ } +/* */ +/* */ public NetworkObject getObject(ObjID objID) { +/* 347 */ return this._objTable.getObject(objID); +/* */ } +/* */ +/* */ public void delObject(ObjID objID) { +/* 351 */ this._objTable.delObject(objID); +/* */ } +/* */ +/* */ public void regObject(ObjID objID, NetworkObject obj) { +/* 355 */ this._objTable.regObject(objID, obj); +/* */ } +/* */ +/* */ +/* */ public void regObject(String longid, NetworkObject obj) +/* */ { +/* 361 */ this._objTable.regObject(new ObjID(longid), obj); +/* */ } +/* */ +/* */ public String getLongID(ObjID objID) { +/* 365 */ return this._objTable.getLongID(objID); +/* */ } +/* */ +/* */ public InetAddress getLocalAddress() { +/* 369 */ if (this._sock != null) +/* 370 */ return this._sock.getLocalAddress(); +/* 371 */ return null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public Galaxy getGalaxy() +/* */ { +/* 379 */ return this._galaxy; +/* */ } +/* */ +/* */ ServerURL getServerURL() { +/* 383 */ return this._serverURL; +/* */ } +/* */ +/* */ void initInstance(Galaxy galaxy, ServerURL serverURL) { +/* 387 */ this._galaxy = galaxy; +/* 388 */ this._serverURL = serverURL; +/* 389 */ this._objTable = new ObjectMgr(this._galaxy); +/* 390 */ this._waiters = new WaitList(this); +/* */ } +/* */ +/* */ public net2Property getProperty(int propID) { +/* 394 */ return this._propList.getProperty(propID); +/* */ } +/* */ +/* */ public int getUpdateTime() { +/* 398 */ return this._updateTime; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ void setUsername(String newUsername) +/* */ { +/* 407 */ if ((getDebugLevel() & 0x4) > 0) { +/* 408 */ System.out.println(this + +/* 409 */ ": Server requested username change to " + +/* 410 */ newUsername); +/* */ } +/* 412 */ this._galaxy.setChatname(newUsername); +/* 413 */ regShortID(1, newUsername); +/* */ } +/* */ +/* 416 */ private Vector<Object> _referrerList = new Vector(); +/* */ private String _scriptServer; +/* */ +/* 419 */ public synchronized void printReferrers() { System.out.println("[" + Std.getRealTime() + "] " + this + +/* 420 */ ": Referrer list -"); +/* 421 */ for (int i = this._referrerList.size() - 1; i >= 0; i--) { +/* 422 */ Object ref = this._referrerList.elementAt(i); +/* 423 */ System.out.println("\t" + ref); +/* */ } +/* 425 */ System.out.println(this + ": Referrer list complete."); +/* */ } +/* */ +/* */ public synchronized Vector<String> printDroneReferrers() { +/* 429 */ Vector<String> list = new Vector(); +/* 430 */ for (int i = this._referrerList.size() - 1; i >= 0; i--) { +/* 431 */ Object ref = this._referrerList.elementAt(i); +/* 432 */ if (ref.toString().startsWith("!")) +/* 433 */ list.addElement(ref.toString()); +/* */ } +/* 435 */ return list; +/* */ } +/* */ +/* */ public synchronized void incRefCnt(Object referrer) { +/* 439 */ if ((this._refCnt == 0) && (!this._isMainRegistered)) { +/* 440 */ Main.register(this); +/* 441 */ this._isMainRegistered = true; +/* */ } +/* 443 */ this._lastAccessTime = Std.getFastTime(); +/* 444 */ this._refCnt += 1; +/* */ +/* */ +/* 447 */ assert (!this._referrerList.removeElement(referrer)); +/* */ +/* 449 */ this._referrerList.addElement(referrer); +/* */ +/* 451 */ if ((getDebugLevel() & 0x1000) > 0) { +/* 452 */ System.out.println(this + ": incRefCnt to " + this._refCnt + " by " + +/* 453 */ referrer); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ public synchronized void tmpRefCnt(Object referrer) +/* */ { +/* 461 */ this._tmpRefCnt += 1; +/* 462 */ boolean existed = this._referrerList.removeElement(referrer); +/* 463 */ assert (existed); +/* */ } +/* */ +/* */ public synchronized void decRefCnt(Object referrer) { +/* 467 */ this._refCnt -= 1; +/* 468 */ boolean existed = this._referrerList.removeElement(referrer); +/* 469 */ assert (existed); +/* */ +/* 471 */ if ((getDebugLevel() & 0x1000) > 0) { +/* 472 */ System.out.println(this + ": decRefCnt to " + this._refCnt + " by " + +/* 473 */ referrer); +/* */ } +/* 475 */ assert (this._refCnt >= 0); +/* */ } +/* */ +/* */ int getRefCnt() { +/* 479 */ return this._refCnt; +/* */ } +/* */ +/* */ public int getVersion() { +/* 483 */ return this._serverProtocolVersion; +/* */ } +/* */ +/* */ public void setVersion(int ver) { +/* 487 */ this._galaxy.setProtocol(ver); +/* 488 */ this._serverProtocolVersion = ver; +/* 489 */ if (this._reader != null) { +/* 490 */ this._reader.setVersion(ver); +/* */ } +/* */ +/* 493 */ if (ver < 18) { +/* 494 */ System.out.println(this + +/* 495 */ ": WARNING: Old server running protocol #17!"); +/* */ } +/* */ } +/* */ +/* */ +/* */ public static int getDebugLevel() +/* */ { +/* 502 */ return Galaxy.getDebugLevel(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ private String _smtpServer; +/* */ +/* */ +/* */ +/* */ private String _mailDomain; +/* */ +/* */ +/* */ public void sendNetworkMsg(netPacket msg) +/* */ throws InfiniteWaitException, PacketTooLargeException +/* */ { +/* 518 */ synchronized (this._state) { +/* 519 */ assert ((this._refCnt != 0) || (this._state.getState() != -1)); +/* 520 */ if (this._state.getState() != 12) +/* 521 */ throw new InfiniteWaitException(); +/* 522 */ sendNetMsg(msg); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int getServerType() +/* */ { +/* 532 */ if (this._propList == null) +/* 533 */ return 1; +/* 534 */ net2Property stProp = this._propList.getProperty(15); +/* 535 */ int servType = 0; +/* */ try { +/* 537 */ servType = Integer.parseInt(stProp.value()); +/* */ } catch (NumberFormatException e) { +/* 539 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* 541 */ return servType; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void setScriptServer(String server) +/* */ { +/* 551 */ if (!server.endsWith("/")) +/* 552 */ server = server + "/"; +/* 553 */ this._scriptServer = server; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public String getScriptServer() +/* */ { +/* 562 */ return this._scriptServer; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void setSmtpServer(String server) +/* */ { +/* 573 */ this._smtpServer = server; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public String getSmtpServer() +/* */ { +/* 581 */ return this._smtpServer; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void setMailDomain(String domain) +/* */ { +/* 591 */ this._mailDomain = domain; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public String getMailDomain() +/* */ { +/* 599 */ return this._mailDomain; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ void sendNetMsg(netPacket msg) +/* */ throws PacketTooLargeException +/* */ { +/* 608 */ assert (msg != null); +/* */ +/* 610 */ if ((getDebugLevel() & 0x80) > 0) { +/* 611 */ System.out.println("[" + Std.getRealTime() + "] " + this + +/* 612 */ ": send(" + msg.toString(this) + ")"); +/* */ } +/* 614 */ if (this._ostr == null) +/* 615 */ return; +/* */ try { +/* 617 */ ByteArrayOutputStream rostr = new ByteArrayOutputStream(256); +/* 618 */ ServerOutputStream ostr = new ServerOutputStream(rostr, getVersion()); +/* 619 */ msg.send(ostr); +/* 620 */ ostr.close(); +/* */ +/* 622 */ if ((getDebugLevel() & 0x400) > 0) { +/* 623 */ byte[] byteArray = rostr.toByteArray(); +/* 624 */ int size = byteArray[0] & 0xFF; +/* 625 */ synchronized (System.out) { +/* 626 */ System.out.print(this + ": send["); +/* 627 */ for (int i = 0; i < size; i++) +/* 628 */ System.out.print(Integer.toString( +/* 629 */ byteArray[i] & 0xFF, 16) + " "); +/* 630 */ System.out.println("]"); +/* */ } +/* */ } +/* */ +/* */ +/* 635 */ synchronized (this._ostr) { +/* 636 */ rostr.writeTo(this._ostr); +/* */ } +/* 638 */ this._lastAccessTime = Std.getFastTime(); +/* */ } +/* */ catch (PacketTooLargeException ptle) { +/* 641 */ throw ptle; +/* */ } catch (IOException e) { +/* 643 */ VarErrorException ve = new VarErrorException( +/* 644 */ 101); +/* 645 */ if (this._lastError == null) +/* 646 */ this._lastError = ve; +/* 647 */ assert (this._connectThread == null); +/* 648 */ this._state.setState(17); +/* */ } +/* */ } +/* */ +/* */ public void sendText(String input) { +/* 653 */ sendText(null, input); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 662 */ private int _lastWhisperTick = 0; +/* 663 */ private int _whisperCnt = 0; +/* */ private Vector<NetworkObject> zombies; +/* */ +/* 666 */ private void _sendText(String who, String msg) { if (msg.length() > 200) { +/* 667 */ Object[] arguments = { new Integer(msg.length()) }; +/* 668 */ Console.println(MessageFormat.format( +/* 669 */ Console.message("msg-too-long"), arguments)); +/* 670 */ msg = msg.substring(0, 199); +/* */ } +/* */ +/* */ +/* 674 */ msg.trim(); +/* 675 */ if (msg.length() < 1) +/* */ { +/* 677 */ return; +/* */ } +/* */ +/* 680 */ if (who == null) { +/* */ try { +/* 682 */ sendNetworkMsg(new textCmd(msg)); +/* */ } +/* */ catch (InfiniteWaitException e) { +/* 685 */ if (msg.startsWith("&|+")) return; +/* 686 */ Console.println(Console.message("not-connected")); +/* */ } +/* */ catch (PacketTooLargeException e) { +/* 689 */ if ($assertionsDisabled) return; } throw new AssertionError(); +/* */ } +/* */ else { +/* 692 */ if (!msg.startsWith("&|+")) { +/* 693 */ Console.printOwnWhisper(who, msg); +/* */ } +/* 695 */ if ((!msg.startsWith("&|+trade>")) && (!who.equalsIgnoreCase("trade"))) +/* */ { +/* */ +/* 698 */ int timeNow = Std.getRealTime(); +/* 699 */ if (timeNow - this._lastWhisperTick > 60000) { +/* 700 */ this._whisperCnt = 0; +/* 701 */ this._lastWhisperTick = timeNow; +/* */ } +/* 703 */ this._whisperCnt += 1; +/* 704 */ if (this._whisperCnt > 15) +/* */ { +/* 706 */ Console.println(Console.message("whisper-too-fast")); +/* 707 */ return; +/* */ } +/* */ } +/* */ try +/* */ { +/* 712 */ sendNetworkMsg(new whisperCmd(who, msg)); +/* */ } catch (PacketTooLargeException e) { +/* 714 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* */ catch (InfiniteWaitException e2) { +/* 717 */ if (!msg.startsWith("&|+")) { +/* 718 */ Console.println(Console.message("not-connected")); +/* */ } +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void sendText(String who, String msg) +/* */ { +/* 730 */ if ((getDebugLevel() & 0x1) > 0) { +/* 731 */ System.out.println("[" + Std.getRealTime() + "] " + this + +/* 732 */ ": sendText(" + msg + ")"); +/* */ } +/* */ +/* 735 */ msg = msg.trim(); +/* */ +/* 737 */ if (msg.length() > 200) +/* */ { +/* */ +/* 740 */ Console.println(Console.message("converting-long")); +/* */ +/* */ +/* */ +/* 744 */ int i1 = 0; +/* 745 */ int i2 = 0; +/* */ +/* 747 */ while (msg.length() - i1 > 200) { +/* 748 */ i2 = msg.lastIndexOf(' ', i1 + 200); +/* */ +/* */ +/* 751 */ if (i2 <= i1) { +/* 752 */ i2 = i1 + 200; +/* */ } +/* 754 */ _sendText(who, msg.substring(i1, i2)); +/* 755 */ i1 = i2 + 1; +/* */ } +/* */ +/* 758 */ _sendText(who, msg.substring(i1)); +/* */ } else { +/* 760 */ _sendText(who, msg); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ public int getState() +/* */ { +/* 768 */ return this._state.getState(); +/* */ } +/* */ +/* */ void setState(int state) { +/* 772 */ this._state.setState(state); +/* */ } +/* */ +/* */ public void waitForConnection() throws InfiniteWaitException { +/* 776 */ this._state.waitForState(12); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void requestRoomID(String roomName, NetworkRoom room) +/* */ { +/* 792 */ this._galaxy.addRoomRequest(roomName, room); +/* 793 */ if (this._state.getState() != 12) +/* */ { +/* */ +/* */ +/* */ +/* */ +/* 799 */ return; +/* */ } +/* */ try { +/* 802 */ sendNetworkMsg(new roomIDReqCmd(roomName)); +/* */ } catch (PacketTooLargeException e) { +/* 804 */ if (!$assertionsDisabled) { throw new AssertionError(); +/* */ } +/* */ } +/* */ catch (InfiniteWaitException localInfiniteWaitException) {} +/* */ } +/* */ +/* */ +/* */ public void delRoomRequest(String roomName) +/* */ { +/* 813 */ this._galaxy.delRoomRequest(roomName); +/* */ } +/* */ +/* */ public void delRoomID(int roomID, NetworkRoom room) { +/* 817 */ this._galaxy.delRoomID(roomID, room); +/* */ } +/* */ +/* */ void regRoomID(int roomID, String roomName, boolean willRedirect) { +/* 821 */ NetworkRoom room = this._galaxy.regRoomID(roomID, roomName); +/* 822 */ if (room != null) +/* */ { +/* */ +/* 825 */ room.setRoomID(this, roomID, roomName, willRedirect); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void redirectRoom(String roomName, ServerURL serverURL) +/* */ { +/* 836 */ NetworkRoom room = (NetworkRoom)this._galaxy.getObject(roomName); +/* 837 */ if (room != null) { +/* 838 */ room.serverRedirect(this, roomName, serverURL); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ NetworkRoom getNetworkRoom(int roomID) +/* */ { +/* 855 */ return this._galaxy.getRoom(roomID); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public final boolean isConnected() +/* */ { +/* 863 */ return this._state.getState() == 12; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ void startConnect() +/* */ { +/* 871 */ synchronized (this._state) { +/* 872 */ int state = this._state.getState(); +/* 873 */ switch (state) { +/* */ case 0: +/* 875 */ assert (this._connectThread == null); +/* 876 */ this._state.setState(3); +/* 877 */ break; +/* */ case 18: +/* 879 */ this._retriesLeft = 5; +/* 880 */ assert (this._connectThread == null); +/* 881 */ this._state.setState(3); +/* */ } +/* */ +/* */ } +/* */ +/* */ +/* */ +/* 888 */ this._lastAccessTime = Std.getFastTime(); +/* */ } +/* */ +/* */ +/* */ +/* */ void forceOffline() +/* */ { +/* 895 */ this._retriesLeft = 0; +/* 896 */ this._lastError = new VarErrorException(205); +/* 897 */ this._requestOffline = true; +/* */ } +/* */ +/* */ void goOnline() +/* */ { +/* 902 */ this._requestOffline = false; +/* */ +/* 904 */ startConnect(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void perFrame(int timeNow) +/* */ { +/* 914 */ synchronized (this._state) +/* */ { +/* */ +/* 917 */ int ServerState = this._state.getState(); +/* 918 */ switch (ServerState) { +/* */ case 12: +/* 920 */ state_Mainloop(timeNow); +/* 921 */ break; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ case 1: +/* */ case 2: +/* 929 */ if (!$assertionsDisabled) { throw new AssertionError(); +/* */ } +/* */ break; +/* */ case 0: +/* */ break; +/* */ case -1: +/* 935 */ state_Dead(timeNow); +/* 936 */ break; +/* */ case 18: +/* 938 */ state_Disconnected(timeNow); +/* 939 */ break; +/* */ case 10: +/* 941 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ break; +/* */ case 14: +/* 944 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ break; +/* */ case 6: +/* */ case 8: +/* */ case 16: +/* 949 */ if (timeNow - this._lastAccessTime > 30000) +/* */ { +/* */ +/* 952 */ if (getDebugLevel() > 0) { +/* 953 */ System.out.println("[" + timeNow + "] " + this + +/* 954 */ ": Messaging timeout. (state=" + +/* 955 */ ServerState + ")"); +/* */ } +/* 957 */ if (this._lastError == null) +/* 958 */ this._lastError = new VarErrorException(106); +/* 959 */ switch (ServerState) { +/* */ case 8: +/* 961 */ this._state.setState(15); +/* 962 */ break; +/* */ case 6: +/* */ case 16: +/* 965 */ this._state.setState(17); +/* */ } +/* */ } +/* */ else { +/* */ try { +/* 970 */ processMsgs(ServerState, timeNow); +/* */ } +/* */ catch (VarErrorException ve) { +/* 973 */ if (getDebugLevel() > 0) { +/* 974 */ System.out.println("[" + timeNow + "] " + this + +/* 975 */ ": VarError#" + ve.getErrorNum()); +/* 976 */ System.out.println(this + ": " + ve.getMsg()); +/* */ } +/* */ +/* 979 */ if (this._lastError == null) +/* 980 */ this._lastError = ve; +/* 981 */ this._state.setState(17); +/* */ } catch (EOFException e) { +/* 983 */ VarErrorException ve = new VarErrorException( +/* 984 */ 100); +/* 985 */ if (this._lastError == null) { +/* 986 */ this._lastError = ve; +/* */ } +/* 988 */ if (getDebugLevel() > 0) { +/* 989 */ synchronized (System.out) { +/* 990 */ e.printStackTrace(System.out); +/* */ } +/* */ } +/* 993 */ this._state.setState(17); +/* */ } catch (IOException e) { +/* 995 */ VarErrorException ve = new VarErrorException( +/* 996 */ 102); +/* 997 */ if (this._lastError == null) { +/* 998 */ this._lastError = ve; +/* */ } +/* 1000 */ synchronized (System.out) { +/* 1001 */ System.out.println("[" + timeNow + "] " + this + +/* 1002 */ ": Read error:"); +/* 1003 */ if (getDebugLevel() > 0) { +/* 1004 */ e.printStackTrace(System.out); +/* */ } +/* */ } +/* 1007 */ this._state.setState(17); +/* */ } catch (Exception e) { +/* 1009 */ VarErrorException ve = new VarErrorException( +/* 1010 */ 103); +/* 1011 */ if (this._lastError == null) { +/* 1012 */ this._lastError = ve; +/* */ } +/* 1014 */ synchronized (System.out) { +/* 1015 */ System.out.println("[" + timeNow + "] " + this + +/* 1016 */ ": Unexpected error:"); +/* 1017 */ e.printStackTrace(System.out); +/* */ } +/* */ +/* 1020 */ this._state.setState(17); +/* */ } +/* */ } +/* */ break; +/* */ case 19: +/* 1025 */ state_Sleeping(timeNow); +/* 1026 */ break; +/* */ case 3: +/* 1028 */ state_Initializing(); +/* 1029 */ break; +/* */ case 4: +/* */ break; +/* */ case 5: +/* 1033 */ state_XMIT_PROPREQ(); +/* 1034 */ break; +/* */ case 7: +/* 1036 */ state_XMIT_SI(); +/* 1037 */ break; +/* */ case 9: +/* 1039 */ state_XMIT_AI(); +/* 1040 */ break; +/* */ case 11: +/* 1042 */ state_XMIT_Props(); +/* 1043 */ break; +/* */ case 13: +/* 1045 */ state_XMIT_AE(); +/* 1046 */ break; +/* */ case 15: +/* 1048 */ state_XMIT_SE(); +/* 1049 */ break; +/* */ case 17: +/* 1051 */ state_Detaching(); +/* */ } +/* */ +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void processMsgs(int state, int timeNow) +/* */ throws Exception +/* */ { +/* 1067 */ int msgsInQueue = this._reader.count(); +/* 1068 */ if (msgsInQueue <= 0) { +/* 1069 */ return; +/* */ } +/* 1071 */ int msgsToProcess = (int)Math.sqrt(this._lastMsgProcCnt * msgsInQueue); +/* */ +/* 1073 */ if (((getDebugLevel() & 0x2) > 0) && (msgsInQueue > 30)) { +/* 1074 */ synchronized (System.out) { +/* 1075 */ System.out.println(this + ": msgs on incoming queue = " + +/* 1076 */ msgsInQueue); +/* 1077 */ System.out.println(" processed approx " + +/* 1078 */ this._lastMsgProcCnt + " messages on last round."); +/* 1079 */ System.out.println(" processing " + msgsToProcess + +/* 1080 */ " messages."); +/* */ } +/* */ } +/* 1083 */ if (5 > msgsToProcess) { +/* 1084 */ this._lastMsgProcCnt = 5; +/* */ } else +/* 1086 */ this._lastMsgProcCnt = msgsToProcess; +/* 1087 */ if (msgsInQueue < msgsToProcess) +/* 1088 */ msgsToProcess = msgsInQueue; +/* 1089 */ msgsToProcess = Math.min(msgsToProcess, msgsInQueue); +/* 1090 */ while (this._state.getState() == state) { +/* 1091 */ if (msgsToProcess-- == 0) +/* */ break; +/* 1093 */ receivedNetPacket p = this._reader.get(); +/* 1094 */ assert (p != null); +/* */ +/* 1096 */ if ((getDebugLevel() & 0x40) > 0) { +/* 1097 */ System.out.println(this + ": recv(" + p.toString(this) + +/* 1098 */ ")"); +/* */ } +/* 1100 */ p.process(this); +/* */ } +/* */ +/* 1103 */ this._lastAccessTime = timeNow; +/* */ } +/* */ +/* */ protected void state_Initializing() { +/* 1107 */ if (this._requestOffline) { +/* 1108 */ this._state.setState(-1); +/* 1109 */ return; +/* */ } +/* 1111 */ if (this._serverURL.getHost().equals("0.0.0.0:0")) +/* */ { +/* 1113 */ System.out.println(this + ": DOA"); +/* */ +/* */ +/* */ +/* 1117 */ this._state.setState(-1); +/* 1118 */ return; +/* */ } +/* */ +/* */ +/* 1122 */ this._objTable.regShortID(255, getLongID()); +/* 1123 */ this._objTable.regObject(getLongID(), this); +/* */ +/* 1125 */ this._lastError = null; +/* */ +/* 1127 */ this._firstLogon = false; +/* */ +/* 1129 */ String host = this._serverURL.getHost(); +/* 1130 */ int port = 5100; +/* 1131 */ assert (host != null); +/* 1132 */ int cindx = this._serverURL.getHost().lastIndexOf(':'); +/* 1133 */ if (cindx >= 0) { +/* */ try { +/* 1135 */ port = Integer.parseInt(this._serverURL.getHost().substring( +/* 1136 */ cindx + 1)); +/* */ } +/* */ catch (NumberFormatException e) { +/* 1139 */ synchronized (System.out) { +/* 1140 */ System.out.println("######DEBUGGING######"); +/* 1141 */ System.out.println(" server: " + +/* 1142 */ this._serverURL.getHost()); +/* 1143 */ System.out.println(" message: " + e.getMessage()); +/* 1144 */ e.printStackTrace(System.out); +/* 1145 */ System.out.println("#####################"); +/* */ } +/* */ +/* 1148 */ VarErrorException ve = new VarErrorException( +/* 1149 */ 103); +/* 1150 */ if (this._lastError == null) { +/* 1151 */ this._lastError = ve; +/* */ } +/* 1153 */ System.out.println("Error in server URL format: " + +/* 1154 */ this._serverURL.getHost()); +/* */ +/* 1156 */ this._state.setState(17); +/* 1157 */ return; +/* */ } +/* 1159 */ host = this._serverURL.getHost().substring(0, cindx); +/* */ } +/* */ +/* */ +/* 1163 */ this._lastAccessTime = Std.getFastTime(); +/* */ +/* */ +/* 1166 */ if (this._currentBackupServer != null) { +/* 1167 */ if (this._sock != null) { +/* */ try { +/* 1169 */ this._sock.close(); +/* */ } +/* */ catch (Exception localException) {} +/* 1172 */ this._sock = null; +/* */ } +/* 1174 */ host = this._currentBackupServer; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1182 */ if (this._sock == null) { +/* 1183 */ this._state.setState(4); +/* 1184 */ assert (this._connectThread == null); +/* 1185 */ this._connectThread = new WSConnecting(this, host, port, 15); +/* */ +/* */ +/* */ +/* */ } +/* 1190 */ else if (this._propList == null) { +/* 1191 */ this._state.setState(5); +/* */ } else { +/* 1193 */ this._state.setState(7); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ protected void setSocket(Socket sock, VarErrorException ve, String host) +/* */ { +/* 1202 */ Vector<String> resolvedHosts = this._connectThread.getBackupHosts(); +/* 1203 */ Enumeration<String> en = resolvedHosts.elements(); +/* 1204 */ while (en.hasMoreElements()) { +/* 1205 */ BackupServer bs = new BackupServer((String)en.nextElement()); +/* */ +/* 1207 */ Enumeration<BackupServer> en2 = this._backupServers.elements(); +/* 1208 */ boolean unique = true; +/* 1209 */ while (en2.hasMoreElements()) +/* */ { +/* 1211 */ if (((BackupServer)en2.nextElement()).GetHost().equals(bs.GetHost())) { +/* 1212 */ unique = false; +/* 1213 */ break; +/* */ } +/* */ } +/* */ +/* 1217 */ if (unique) { +/* 1218 */ this._backupServers.addElement(bs); +/* */ } +/* 1220 */ if ((host != null) && +/* 1221 */ (host.equals(bs.GetHost()))) { +/* 1222 */ bs.IncTries(); +/* */ } +/* */ } +/* */ +/* 1226 */ this._connectThread = null; +/* 1227 */ if (this._state.getState() != 4) +/* */ { +/* 1229 */ return; +/* */ } +/* 1231 */ if (sock == null) { +/* 1232 */ assert (ve != null); +/* 1233 */ if (this._lastError == null) +/* 1234 */ this._lastError = ve; +/* 1235 */ this._state.setState(17); +/* 1236 */ return; +/* */ } +/* 1238 */ this._sock = sock; +/* */ try +/* */ { +/* 1241 */ this._ostr = this._sock.getOutputStream(); +/* */ +/* */ +/* 1244 */ this._reader = new netPacketReader(this, new ServerInputStream( +/* 1245 */ this._sock.getInputStream())); +/* */ +/* */ +/* */ +/* */ +/* 1250 */ this._reader.setVersion(getVersion()); +/* */ } catch (Exception e) { +/* 1252 */ ve = new VarErrorException(105); +/* 1253 */ if (this._lastError == null) { +/* 1254 */ this._lastError = ve; +/* */ } +/* 1256 */ System.out.println(this + ": Error opening I/O streams."); +/* */ +/* 1258 */ this._state.setState(17); +/* 1259 */ return; +/* */ } +/* 1261 */ this._reader.setDaemon(true); +/* */ +/* 1263 */ this._reader.start(); +/* 1264 */ this._state.setState(5); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void state_XMIT_PROPREQ() +/* */ { +/* 1273 */ if (this._requestOffline) { +/* 1274 */ this._state.setState(17); +/* 1275 */ return; +/* */ } +/* 1277 */ propReqCmd propReq = new propReqCmd(new ObjID(255)); +/* 1278 */ if (NetUpdate.isInternalVersion()) +/* */ { +/* */ +/* */ +/* 1282 */ propReq.addProp(1); +/* 1283 */ propReq.addProp(3); +/* 1284 */ propReq.addProp(15); +/* 1285 */ propReq.addProp(29); +/* 1286 */ propReq.addProp(25); +/* 1287 */ propReq.addProp(26); +/* 1288 */ propReq.addProp(27); +/* */ } +/* */ try { +/* 1291 */ sendNetMsg(propReq); +/* */ } catch (PacketTooLargeException p) { +/* 1293 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* 1295 */ this._state.setState(6); +/* */ } +/* */ +/* */ protected void state_XMIT_SI() +/* */ { +/* 1300 */ if (!$assertionsDisabled) throw new AssertionError(); +/* 1301 */ if (this._requestOffline) { +/* 1302 */ this._state.setState(17); +/* 1303 */ return; +/* */ } +/* 1305 */ this._galaxy.addPendingServer(this); +/* 1306 */ this._state.setState(8); +/* */ } +/* */ +/* */ +/* */ +/* */ protected void state_XMIT_AI() +/* */ { +/* 1313 */ if (!$assertionsDisabled) throw new AssertionError(); +/* 1314 */ if (this._requestOffline) { +/* 1315 */ this._state.setState(17); +/* 1316 */ return; +/* */ } +/* 1318 */ this._state.setState(11); +/* */ } +/* */ +/* */ protected void state_XMIT_Props() { +/* 1322 */ if (this._requestOffline) { +/* 1323 */ this._state.setState(15); +/* 1324 */ return; +/* */ } +/* 1326 */ this._state.setState(12); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1332 */ this._galaxy.addActiveServer(this); +/* */ } +/* */ +/* */ +/* */ +/* */ protected void state_Mainloop(int timeNow) +/* */ { +/* 1339 */ killZombies(); +/* */ +/* 1341 */ if (this._requestOffline) { +/* 1342 */ this._state.setState(15); +/* 1343 */ return; +/* */ } +/* 1345 */ if (timeNow - this._lastAccessTime > 120000) +/* */ { +/* 1347 */ if (getDebugLevel() > 0) { +/* 1348 */ System.out.println(this + ": Timeout during connection."); +/* */ } +/* 1350 */ System.out.println("[" + timeNow + "] " + this + +/* 1351 */ ": Timeout during connection."); +/* 1352 */ System.out.println("\t_lastAccessTime = " + this._lastAccessTime); +/* 1353 */ System.out.println("\t timeNow = " + timeNow); +/* 1354 */ this._retriesLeft = 0; +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1360 */ this._state.setState(15); +/* 1361 */ return; +/* */ } +/* */ +/* */ +/* 1365 */ this._waiters.notify(true); +/* */ try +/* */ { +/* 1368 */ processMsgs(12, timeNow); +/* */ } catch (VarErrorException ve) { +/* 1370 */ if (!$assertionsDisabled) throw new AssertionError(); +/* 1371 */ this._state.setState(17); +/* */ } catch (EOFException e) { +/* 1373 */ VarErrorException ve = new VarErrorException(100); +/* 1374 */ if (this._lastError == null) { +/* 1375 */ this._lastError = ve; +/* */ } +/* 1377 */ synchronized (System.out) { +/* 1378 */ System.out.println("[" + timeNow + "] " + this + +/* 1379 */ ": Server has shut down connection."); +/* 1380 */ if (getDebugLevel() > 0) { +/* 1381 */ e.printStackTrace(System.out); +/* */ } +/* */ } +/* 1384 */ this._state.setState(17); +/* */ } catch (IOException e) { +/* 1386 */ VarErrorException ve = new VarErrorException(100); +/* 1387 */ if (this._lastError == null) { +/* 1388 */ this._lastError = ve; +/* */ } +/* 1390 */ synchronized (System.out) { +/* 1391 */ System.out.println("[" + timeNow + "] " + this + +/* 1392 */ ": Error reading from network."); +/* 1393 */ if (getDebugLevel() > 0) { +/* 1394 */ e.printStackTrace(System.out); +/* */ } +/* */ } +/* 1397 */ this._state.setState(17); +/* */ } catch (Exception e) { +/* 1399 */ VarErrorException ve = new VarErrorException( +/* 1400 */ 103); +/* 1401 */ if (this._lastError == null) { +/* 1402 */ this._lastError = ve; +/* */ } +/* 1404 */ synchronized (System.out) { +/* 1405 */ System.out.println("[" + timeNow + "] " + this + +/* 1406 */ ": Unexpected error."); +/* 1407 */ e.printStackTrace(System.out); +/* */ } +/* */ +/* 1410 */ this._state.setState(17); +/* */ } +/* */ } +/* */ +/* */ protected void state_XMIT_AE() { +/* 1415 */ if (!$assertionsDisabled) throw new AssertionError(); +/* 1416 */ this._state.setState(14); +/* */ +/* 1418 */ this._state.setState(15); +/* */ } +/* */ +/* */ protected void state_XMIT_SE() { +/* 1422 */ boolean sendVAR_LOGONOFF = this._galaxy.addClosingServer(this); +/* 1423 */ OldPropertyList propList = new OldPropertyList(); +/* 1424 */ if (sendVAR_LOGONOFF) { +/* 1425 */ propList.addProperty(new netProperty(12, "1")); +/* */ } +/* */ try { +/* 1428 */ sendNetMsg(new sessionExitCmd(propList)); +/* */ } catch (PacketTooLargeException e) { +/* 1430 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* 1432 */ this._state.setState(16); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void reuseConnection(WorldServer src) +/* */ { +/* 1441 */ this._reader = src._reader; +/* 1442 */ src._reader = null; +/* 1443 */ this._ostr = src._ostr; +/* 1444 */ src._ostr = null; +/* 1445 */ this._sock = src._sock; +/* 1446 */ src._sock = null; +/* */ +/* */ +/* 1449 */ this._backupServers = ((Vector)src._backupServers.clone()); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public boolean useBackupServer() +/* */ { +/* 1458 */ Enumeration<BackupServer> enums = this._backupServers.elements(); +/* 1459 */ while (enums.hasMoreElements()) { +/* 1460 */ BackupServer bs = (BackupServer)enums.nextElement(); +/* 1461 */ if (bs.tries == 0) { +/* 1462 */ bs.IncTries(); +/* 1463 */ this._currentBackupServer = bs.GetHost(); +/* 1464 */ return true; +/* */ } +/* */ } +/* */ +/* 1468 */ this._currentBackupServer = null; +/* 1469 */ return false; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ private void addZombies() +/* */ { +/* 1484 */ Enumeration<NetworkObject> enums = this._objTable.objects(); +/* 1485 */ while (enums.hasMoreElements()) { +/* 1486 */ NetworkObject no = (NetworkObject)enums.nextElement(); +/* 1487 */ if ((no instanceof WObject)) { +/* 1488 */ if (this.zombies == null) { +/* 1489 */ this.zombies = new Vector(); +/* */ } +/* 1491 */ this.zombies.addElement(no); +/* 1492 */ } else if ((no instanceof Drone)) { +/* 1493 */ ((Drone)no).disappear(); +/* */ } +/* */ } +/* 1496 */ this._objTable.clear(); +/* */ } +/* */ +/* */ public void killZombies() { +/* 1500 */ if (this.zombies != null) { +/* 1501 */ int i = this.zombies.size(); +/* */ do { +/* 1503 */ NetworkObject no = (NetworkObject)this.zombies.elementAt(i); +/* */ +/* */ +/* */ +/* 1507 */ this._objTable.regObject(no.getLongID(), no); +/* 1508 */ if ((no instanceof Drone)) { +/* 1509 */ ((Drone)no).disappear(); +/* */ } +/* 1502 */ i--; } while (i >= 0); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1512 */ this.zombies = null; +/* */ } +/* */ } +/* */ +/* */ private void cleanup() { +/* 1517 */ assert (this._objTable != null); +/* */ +/* */ +/* 1520 */ if ((this._lastError == null) || (this._lastError.getStatusFlag())) +/* */ { +/* 1522 */ killZombies(); +/* 1523 */ Enumeration<NetworkObject> enums = this._objTable.objects(); +/* 1524 */ while (enums.hasMoreElements()) { +/* 1525 */ NetworkObject no = (NetworkObject)enums.nextElement(); +/* 1526 */ if ((no instanceof Drone)) { +/* 1527 */ ((Drone)no).disappear(); +/* */ } +/* */ } +/* 1530 */ this._objTable.clear(); +/* */ } +/* */ else { +/* 1533 */ addZombies(); +/* */ } +/* */ +/* 1536 */ if (this._reader != null) { +/* 1537 */ if (this._reader.isAlive()) { +/* 1538 */ this._reader.stop(); +/* */ } +/* 1540 */ this._reader = null; +/* */ } +/* */ +/* 1543 */ if (this._ostr != null) { +/* */ try { +/* 1545 */ this._ostr.close(); +/* */ } +/* */ catch (Exception localException) {} +/* */ +/* 1549 */ this._ostr = null; +/* */ } +/* */ +/* 1552 */ if (this._sock != null) { +/* */ try { +/* 1554 */ this._sock.close(); +/* */ } +/* */ catch (Exception localException1) {} +/* */ +/* 1558 */ this._sock = null; +/* */ } +/* */ +/* 1561 */ assert (this._connectThread == null); +/* */ } +/* */ +/* */ protected void state_Detaching_helper() { +/* 1565 */ if (this._galaxy != null) { +/* 1566 */ this._galaxy.addClosingServer(this); +/* 1567 */ this._galaxy.markClosedServer(this); +/* */ } +/* */ +/* 1570 */ cleanup(); +/* */ +/* 1572 */ this._retryTimeout = 60000; +/* */ +/* 1574 */ if (this._galaxy != null) +/* */ { +/* */ +/* 1577 */ this._galaxy.noteServerDeath(this._lastError); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void state_Detaching() +/* */ { +/* 1592 */ this._state.setState(18); +/* */ +/* 1594 */ state_Detaching_helper(); +/* */ +/* 1596 */ if (this._lastError != null) +/* */ { +/* 1598 */ System.out.println("[" + Std.getRealTime() + "] " + this + +/* 1599 */ ": lastError=" + this._lastError); +/* */ +/* 1601 */ this._lastError = null; +/* */ +/* */ +/* */ +/* */ +/* 1606 */ this._galaxy.reacquireServer(this); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ } +/* 1645 */ else if (this._refCnt - this._tmpRefCnt > 0) { +/* 1646 */ startConnect(); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected void state_Sleeping(int timeNow) +/* */ { +/* 1657 */ if (this._requestOffline) { +/* 1658 */ this._state.setState(-1); +/* 1659 */ return; +/* */ } +/* 1661 */ if (timeNow - this._lastAccessTime > this._retryTimeout) { +/* 1662 */ if (this._refCnt == 0) { +/* 1663 */ this._state.setState(18); +/* */ +/* */ } +/* */ else +/* */ { +/* 1668 */ this._state.setState(3); +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ protected void state_Disconnected(int timeNow) +/* */ { +/* 1677 */ this._waiters.notify(false); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1688 */ if (timeNow - this._lastAccessTime > 1800000) { +/* 1689 */ synchronized (this) +/* */ { +/* */ +/* 1692 */ if (this._refCnt == 0) +/* */ { +/* */ +/* */ +/* */ +/* 1697 */ assert (this._isMainRegistered); +/* 1698 */ Main.unregister(this); +/* 1699 */ this._isMainRegistered = false; +/* */ +/* 1701 */ if (this._galaxy != null) { +/* 1702 */ this._galaxy.killServer(this); +/* */ } +/* */ } +/* */ } +/* */ } +/* 1707 */ this._lastAccessTime = timeNow; +/* */ } +/* */ +/* */ protected void state_Dead(int timeNow) +/* */ { +/* 1712 */ killZombies(); +/* */ +/* */ +/* */ +/* */ +/* 1717 */ state_Disconnected(timeNow); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ public void mainCallback() +/* */ { +/* 1725 */ int t = Std.getRealTime(); +/* 1726 */ perFrame(t); +/* */ +/* */ +/* */ +/* 1730 */ if (((getDebugLevel() & 0x1000) > 0) && (this._tmpRefCnt > 0)) { +/* 1731 */ System.out.println(this + ": tmpRefCnt cleanup of " + +/* 1732 */ this._tmpRefCnt + " refs."); +/* */ } +/* 1734 */ synchronized (this) { +/* 1735 */ this._refCnt -= this._tmpRefCnt; +/* 1736 */ this._tmpRefCnt = 0; +/* */ } +/* 1738 */ assert (this._refCnt >= 0); +/* */ } +/* */ +/* */ public void terminalCallback() +/* */ { +/* 1743 */ synchronized (this) { +/* 1744 */ if (this._isMainRegistered) { +/* 1745 */ Main.unregister(this); +/* */ } +/* */ +/* */ +/* 1749 */ Galaxy.forceOffline(false); +/* */ +/* */ +/* 1752 */ if (this._lastError == null) { +/* 1753 */ this._lastError = new VarErrorException(201); +/* */ } +/* 1755 */ this._retriesLeft = 0; +/* 1756 */ int state = this._state.getState(); +/* */ +/* 1758 */ this._state.setState(-1); +/* 1759 */ switch (state) +/* */ { +/* */ case 8: +/* */ case 9: +/* */ case 10: +/* */ case 11: +/* */ case 12: +/* */ case 15: +/* 1767 */ if ((getDebugLevel() & 0x200) > 0) { +/* 1768 */ System.out.println(this + +/* 1769 */ ": terminalCallback(): XMIT_SE, Detach"); +/* */ } +/* 1771 */ state_XMIT_SE(); +/* 1772 */ state_Detaching(); +/* 1773 */ break; +/* */ case 4: +/* 1775 */ this._connectThread = null; +/* */ +/* */ +/* */ case 7: +/* */ case 16: +/* */ case 17: +/* 1781 */ if ((getDebugLevel() & 0x200) > 0) { +/* 1782 */ System.out.println(this + +/* 1783 */ ": terminalCallback(): Detach"); +/* */ } +/* 1785 */ state_Detaching(); +/* 1786 */ break; +/* */ case 5: case 6: case 13: +/* */ case 14: default: +/* 1789 */ if ((getDebugLevel() & 0x200) > 0) { +/* 1790 */ System.out.println(this + +/* 1791 */ ": terminalCallback(): no operation"); +/* */ } +/* */ +/* */ break; +/* */ } +/* */ +/* */ } +/* */ } +/* */ +/* */ public void waitForConnection(ConnectionWaiter cw) +/* */ { +/* 1802 */ this._waiters.addWaiter(cw); +/* */ } +/* */ +/* */ public void abortWaitForConnection(ConnectionWaiter cw) { +/* 1806 */ this._waiters.abortWait(cw); +/* */ } +/* */ +/* */ public String toString() +/* */ { +/* 1811 */ return getLongID(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void property(OldPropertyList propList) +/* */ { +/* 1820 */ if (!$assertionsDisabled) { throw new AssertionError(); +/* */ } +/* */ } +/* */ +/* */ public void propertyUpdate(PropertyList propList) +/* */ { +/* 1826 */ this._propList = propList; +/* 1827 */ net2Property protocol = this._propList.getProperty(3); +/* 1828 */ if (protocol != null) { +/* */ int ver; +/* */ try { +/* 1831 */ ver = Integer.parseInt(protocol.value()); +/* */ } catch (NumberFormatException e) { int ver; +/* 1833 */ System.err.println(this + ": Error converting protocol value: " + +/* 1834 */ protocol.value()); +/* 1835 */ ver = 18; +/* */ } +/* 1837 */ int oldVer = getVersion(); +/* */ +/* 1839 */ setVersion(ver < oldVer ? ver : oldVer); +/* */ } +/* 1841 */ net2Property update = this._propList.getProperty(8); +/* 1842 */ if (update != null) { +/* */ try { +/* 1844 */ this._updateTime = Integer.parseInt(update.value()); +/* 1845 */ this._updateTime /= 1000; +/* */ } catch (NumberFormatException e) { +/* 1847 */ System.err.println(this + ": Error converting update value: " + +/* 1848 */ update.value()); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 1859 */ net2Property http = this._propList.getProperty(24); +/* 1860 */ if (http == null) +/* 1861 */ http = this._propList.getProperty(29); +/* 1862 */ if (http != null) { +/* 1863 */ NetUpdate.setUpgradeServerURL(http.value()); +/* */ } +/* */ +/* */ +/* */ +/* 1868 */ net2Property script = this._propList.getProperty(25); +/* 1869 */ if (script != null) +/* 1870 */ setScriptServer(script.value()); +/* 1871 */ net2Property smtp = this._propList.getProperty(26); +/* 1872 */ if (smtp != null) +/* 1873 */ setSmtpServer(smtp.value()); +/* 1874 */ net2Property domain = this._propList.getProperty(27); +/* 1875 */ if (domain != null) { +/* 1876 */ setMailDomain(domain.value()); +/* */ } +/* 1878 */ if (this._state.getState() == 6) { +/* 1879 */ this._state.setState(7); +/* */ } +/* */ } +/* */ +/* */ public WorldServer getServer() { +/* 1884 */ return this; +/* */ } +/* */ +/* */ public String getLongID() +/* */ { +/* 1889 */ return this._serverURL.getHost(); +/* */ } +/* */ +/* */ +/* */ +/* */ public void register() +/* */ { +/* 1896 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* */ +/* */ public void galaxyDisconnected() +/* */ { +/* 1901 */ if (!$assertionsDisabled) throw new AssertionError(); +/* */ } +/* */ +/* */ public void reacquireServer(WorldServer oldServer) {} +/* */ +/* */ public void changeChannel(Galaxy g, String oldChannel, String newChannel) {} +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\WorldServer.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |