/// <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); } }
/// <summary> /// 一条消息处理完成后的回调 /// </summary> /// <param name="client"></param> /// <param name="msg"></param> private void ReceiveProcessCompleted(ClientPeer client, NetMsg msg) { //交给应用层处理完成后的回调 application.Receive(client, msg); }
public void Enqueue(ClientPeer client) { clientPeerQueue.Enqueue(client); }