//--------------------------------------------------------------------- public void close() { if (mSocket != null) { mSocket.close(); mSocket = null; } }
//------------------------------------------------------------------------- void _sessionClosed(SuperSocketSession s, CloseReason reason) { SessionEvent e; e.new_or_close = false; e.s = s; e.reason = reason; mQueSessionEvent.Enqueue(e); }
//------------------------------------------------------------------------- void _newSessionConnected(SuperSocketSession s) { SessionEvent e; e.new_or_close = true; e.s = s; e.reason = CloseReason.Unknown; mQueSessionEvent.Enqueue(e); }
//--------------------------------------------------------------------- void _onSocketError(string error) { mSocket = null; if (OnSocketError != null) { OnSocketError(error); } }
//--------------------------------------------------------------------- void _onSocketClose(SessionCloseReason reason) { mSocket = null; if (OnSocketClosed != null) { OnSocketClosed(reason); } }
//--------------------------------------------------------------------- public EntityRpcSessionSuperSocketS(EntityMgr entity_mgr, SuperSocketSession socket) { mEntityMgr = entity_mgr; mSocket = socket; mSocket.OnSocketClosed = _onSocketClose; mSocket.OnSocketReceive = _onSocketReceive; mSocket.OnSocketError = _onSocketError; socket.IsConnected = true; }
//------------------------------------------------------------------------- public void sessionClosed(SuperSocketSession s, CloseReason reason) { if (OnSessionDestroy != null && s.UserData != null) { SessionCloseReason r = (SessionCloseReason)reason; EntityRpcSessionSuperSocketS rs = (EntityRpcSessionSuperSocketS)s.UserData; OnSessionDestroy((IRpcSession)rs, r); } }
//------------------------------------------------------------------------- public void newSessionConnected(SuperSocketSession s) { if (OnSessionCreate != null) { var rs = new EntityRpcSessionSuperSocketS(EntityMgr, s); s.UserData = rs; OnSessionCreate((IRpcSession)rs, s.RemoteEndPoint); } }
//--------------------------------------------------------------------- void _newRequestReceived(SuperSocketSession session, BufferedPackageInfo <ushort> packet) { session._onSocketRecv(packet); }