diff options
Diffstat (limited to 'NET/worlds/network/AutoServer.java')
| -rw-r--r-- | NET/worlds/network/AutoServer.java | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/NET/worlds/network/AutoServer.java b/NET/worlds/network/AutoServer.java new file mode 100644 index 0000000..e4f84cf --- /dev/null +++ b/NET/worlds/network/AutoServer.java @@ -0,0 +1,85 @@ +package NET.worlds.network; + +import NET.worlds.console.Console; + +public class AutoServer extends WorldServer { + private static int counter = 0; + + public AutoServer() { + if (counter++ > 0) { + System.out.println("DEBUG: Created second AutoServer class."); + Galaxy.printDebugging(); + new Exception().printStackTrace(System.out); + } + } + + @Override + public synchronized void incRefCnt(Object referrer) { + super.incRefCnt(referrer); + this.startConnect(); + } + + protected void state_Authprompt() { + this._state.setState(3); + } + + @Override + protected void state_XMIT_SI() { + WorldServer newServer = null; + int servType = this.getServerType(); + if ((getDebugLevel() & 32) > 0) { + System.out.println(this + ": AutoServer detected server type " + servType); + } + + switch (servType) { + case 1: + newServer = new UserServer(); + break; + case 2: + newServer = new AnonUserServer(); + break; + case 3: + Console.println(this + Console.message("Error-in-server")); + Console.println(this + Console.message("Error-user-server")); + newServer = null; + break; + case 4: + newServer = new AnonRoomServer(); + break; + default: + assert false; + } + + if (newServer != null) { + newServer.reuseConnection(this); + newServer.initInstance(this._galaxy, this._serverURL); + newServer.propertyUpdate(this._propList); + } + + this._galaxy.killServer(this); + this._galaxy.swapServer(this, newServer); + this._galaxy.setGalaxyType(servType); + if (this._refCnt - this._tmpRefCnt != 0) { + System.out.println(this + ": bad reference counts. DEBUG INFO:"); + System.out.println("\t_refCnt = " + this._refCnt); + System.out.println("\t_tmpRefCnt = " + this._tmpRefCnt); + this.printReferrers(); + } + + assert this._refCnt - this._tmpRefCnt == 0; + + this._state.setState(17); + } + + @Override + public String toString() { + return "AutoServer(" + super.toString() + ")"; + } + + @Override + void goOnline() { + super.goOnline(); + System.out.println("DEBUG: AutoServer going online!"); + new Exception().printStackTrace(System.out); + } +} |