public void Disconnect() { if (Server != null) { WorldServerManager.Instance.RemoveWorld(Server); } if (m_operations != null) { m_operations.Dispose(); } Server = null; m_operations = null; }
protected override void ProcessRequest(IPCMessage message) { if (m_operations == null) { if (!(message is HandshakeMessage)) { SendError(string.Format("The first received packet should be a HandshakeMessage not {0}", message.GetType())); Disconnect(); } else { HandshakeMessage handshakeMessage = message as HandshakeMessage; WorldServer server; try { server = WorldServerManager.Instance.RequestConnection(this, handshakeMessage.World); } catch (Exception exception) { SendError(exception); Disconnect(); return; } Server = server; m_operations = new IPCOperations(this); Send(new CommonOKMessage { RequestGuid = message.RequestGuid }); } } else { if (message.RequestGuid != Guid.Empty) { m_currentRequest = message; } else { m_currentRequest = null; } try { m_operations.HandleMessage(message); } catch (Exception exception) { SendError(exception); } } }
protected override void ProcessMessage(IPCMessage message) { // handshake not done yet if (m_operations == null) { if (!(message is HandshakeMessage)) { SendError(string.Format("The first received packet should be a HandshakeMessage not {0}", message.GetType()), message); Disconnect(); } else { // the handshake is managed by the IO thread, the other messages by an other DB connection AuthServer.Instance.IOTaskPool.AddMessage(() => { var handshake = message as HandshakeMessage; WorldServer server; try { server = WorldServerManager.Instance.RequestConnection(this, handshake.World); } catch (Exception ex) { SendError(ex, message); Disconnect(); return; } Server = server; m_operations = new IPCOperations(this); // guid setted manually cause the request is not stored ReplyRequest(new CommonOKMessage(), message); }); } } else { base.ProcessMessage(message); } }
public void Disconnect() { if (Socket != null && Socket.Connected) { Socket.Close(); } if (Server != null) { WorldServerManager.Instance.RemoveWorld(Server); } if (m_operations != null) { m_operations.Dispose(); } Server = null; m_operations = null; TaskPool.ExecuteInContext(() => OnDisconnected()); }