Exemplo n.º 1
0
 /// <summary>
 /// 被动断开会话 比如客户端断开连接
 /// </summary>
 /// <param name="disConnectArgs"></param>
 protected virtual void OnDisConnect(DisConnectArgs disConnectArgs)
 {
     try
     {
         _socketBufferManager.FreeBuffer(disConnectArgs.Session.SocketAsyncEventArgs);
         _socketAsyncEventArgsPool.Push(disConnectArgs.Session.SocketAsyncEventArgs);
         _socketSessionManager.Remove(disConnectArgs.Session.Id);
         _socketServerEvent.OnDisConnected(AppSocketContainer.Ins, disConnectArgs);
         _logger.DebugFormat("客户端{0}断开连接!", disConnectArgs.Session.SocketAsyncEventArgs.AcceptSocket.RemoteEndPoint.ToString());
         _logger.DebugFormat("当前Session数{0}!", _socketSessionManager.Count);
         _logger.DebugFormat("当前SocketAsyncEventArgs剩余数{0}!", _socketAsyncEventArgsPool.Count);
         disConnectArgs.Session.SocketAsyncEventArgs.AcceptSocket.Close();
         disConnectArgs.Session.SocketAsyncEventArgs.AcceptSocket.Dispose();
         disConnectArgs.Session.SocketAsyncEventArgs.AcceptSocket = null;
         disConnectArgs.Session.SocketAsyncEventArgs.UserToken = null;
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
     }
 }
Exemplo n.º 2
0
 public virtual void OnDisConnected(DisConnectArgs disConnectArgs)
 {
     DisConnected(this, disConnectArgs);
 }
Exemplo n.º 3
0
        void Client_DisConnected(object sender, DisConnectArgs e)
        {
            BeginInvoke(new MethodInvoker(() =>
            {
                Interlocked.Decrement(ref _connectCount);
                var client = sender as DefaultAppTcpSocketClient;
                lbStatus.Items.Insert(0, "与服务器断开连接!" + client["GpsCode"]);
            }));

            
        }
Exemplo n.º 4
0
 /// <summary>
 /// 断开连接
 /// </summary>
 /// <param name="container"></param>
 /// <param name="disConnectArgs"></param>
 public virtual void OnDisConnected(AppSocketContainer container, DisConnectArgs disConnectArgs)
 {
 }