//------------------------------------------------------------------------- async void _onSuperSocketSessionDestroy(IRpcSession s, SessionCloseReason reason) { ClientInfo client_info = getClientInfoThenRemove(s); if (client_info == null) { return; } EbLog.Note("玩家连接断开,EtPlayerGuid=" + client_info.et_player_guid); try { if (client_info.player_watcher_weak != null && !string.IsNullOrEmpty(client_info.et_player_guid)) { var grain_player = GrainClient.GrainFactory.GetGrain <ICellPlayer>(new Guid(client_info.et_player_guid)); await grain_player.unsubPlayer(client_info.player_watcher_weak); client_info.remote_endpoint = null; client_info.player_watcher = null; client_info.player_watcher_weak = null; } } catch (Exception ex) { EbLog.Error(ex.ToString()); } }
//--------------------------------------------------------------------- void _onSocketClose(SessionCloseReason reason) { mSocket = null; if (OnSocketClosed != null) { OnSocketClosed(reason); } }
//------------------------------------------------------------------------- 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); } }
private void TerminateSession(SessionCloseReason reason, Exception exception) { //shutdown socket vSocket.Shutdown(SocketShutdown.Both); //disconnect socket vSocket.Disconnect(false); //Close to release any resources claimed by the socket instance vSocket.Close(); RaiseSessionClosedEvent(reason, exception); }
//--------------------------------------------------------------------- protected override void OnSessionClosed(CloseReason reason) { lock (mLockWorker) { SessionCloseReason r = (SessionCloseReason)reason; SocketEvent socket_event; socket_event.type = eSocketEventType.Closed; socket_event.args = r; mSocketEvent.Enqueue(socket_event); } }
private void RaiseSessionClosedEvent(SessionCloseReason reason, Exception ex) { if (SessionClosed == null) { return; } foreach (EventHandler <TcpIpSessionClosedEventArgs> del in SessionClosed.GetInvocationList()) { SessionClosed.BeginInvoke(this, new TcpIpSessionClosedEventArgs(reason, ex), AsyncCallBackRaiseSessionClosedEvent, del); } }
private void RaiseSessionClosedEvent(SessionCloseReason reason, Exception ex) { if (SessionClosed == null) { return; } foreach (EventHandler <TcpIpSessionClosedEventArgs> del in SessionClosed.GetInvocationList()) { #if NET40 SessionClosed.BeginInvoke(this, new TcpIpSessionClosedEventArgs(reason, ex), AsyncCallBackRaiseSessionClosedEvent, del); #else System.Threading.Tasks.Task.Run(() => SessionClosed.Invoke(this, new TcpIpSessionClosedEventArgs(reason, ex))); #endif } }
//--------------------------------------------------------------------- void _processSocketEvent(eSocketEventType type, object args) { switch (type) { case eSocketEventType.Connected: { if (OnSocketConnected != null) { OnSocketConnected(); } } break; case eSocketEventType.Closed: { SessionCloseReason reason = (SessionCloseReason)args; if (OnSocketClosed != null) { SessionCloseReason r = (SessionCloseReason)reason; OnSocketClosed(r); } } break; case eSocketEventType.Error: { if (OnSocketError != null) { OnSocketError(args.ToString()); } } break; case eSocketEventType.UnknownRequest: { if (OnSocketError != null) { OnSocketError("HandleUnknownRequest"); } } break; } }
/// <summary> /// 关闭会话 /// </summary> /// <param name="reason"></param> public void Close(SessionCloseReason reason) { if (Interlocked.CompareExchange(ref _closeFlag, 1, 0) == 1) { return; } if (UnderlineSocket.Connected) { UnderlineSocket.Shutdown(SocketShutdown.Both); } UnderlineSocket.Close(); UnderlineSocket = null; //_receiveAsyncEventArgs.Dispose(); //_receiveAsyncEventArgs = null; _receiveBuffer = null; _extractor = null; Loop.Ins.Perform(() => { _dispatcher.OnClose(this, reason); }); }
private void RaiseSessionClosedEvent(SessionCloseReason reason, Exception ex) { if (SessionClosed == null) { return; } foreach (EventHandler<TcpIpSessionClosedEventArgs> del in SessionClosed.GetInvocationList()) { SessionClosed.BeginInvoke(this, new TcpIpSessionClosedEventArgs(reason, ex), AsyncCallBackRaiseSessionClosedEvent, del); } }
public TcpIpSessionClosedEventArgs(SessionCloseReason reason, Exception exception) { vReason = reason; vException = exception; }
public void OnClose(Session session, SessionCloseReason reason) { Logger.Ins.Debug($"{session.Name} closed by {reason}!"); _dispatcher?.OnClose(session, reason); _closeHandler?.Invoke(reason); }
public virtual void OnClose(Session session, SessionCloseReason reason) { Logger.Ins.Warn("You should override OnClose."); }
public TcpIpSessionClosedEventArgs(SessionCloseReason reason, Exception exception) { _vReason = reason; _vException = exception; }
public bool RemoveSession(ushort id, SessionCloseReason reason) { Session session; return(_items.TryRemove(id, out session)); }