Ejemplo n.º 1
0
 /// <summary>
 /// 客户端断开连接
 /// </summary>
 /// <param name="client"></param>
 /// <param name="reason"></param>
 private void Disconnect(ClientPeer client, string reason)
 {
     try
     {
         if (client == null)
         {
             throw new Exception("客户端为空,无法断开连接");
         }
         Console.WriteLine(client.clientSocket.RemoteEndPoint + "客户端断开连接,原因:" + reason);
         application.Disconnect(client);
         //让客户端断开连接
         client.DisConnect();
         clientPeerPool.Enqueue(client);
         semaphore.Release();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 一条消息处理完成后的回调
 /// </summary>
 /// <param name="client"></param>
 /// <param name="msg"></param>
 private void ReceiveProcessCompleted(ClientPeer client, NetMsg msg)
 {
     //交给应用层处理完成后的回调
     application.Receive(client, msg);
 }
Ejemplo n.º 3
0
 public void Enqueue(ClientPeer client)
 {
     clientPeerQueue.Enqueue(client);
 }