/// <summary> /// 释放用户 /// </summary> /// <param name="key"></param> public void DropConnUser(string key) { lock (ConnUserList) { if (ConnUserList.ContainsKey(key)) { ConnUserList[key].Sock.Close(); ConClient client; ConnUserList.TryRemove(key, out client); } } }
void client_ExpOUtPut(ConClient conClient, string Message) { if (ConnUserList.ContainsKey(conClient.Key)) { ConnUserList.TryRemove(conClient.Key, out conClient); } LogOut.LogIn(string.Format("客户连接断开 {0}:{1}", conClient.Host + ":" + conClient.Port, conClient.Key), ActionType.Message); if (ClientDiscon != null) { ClientDiscon(conClient, string.Format("客户连接断开 {0}:{1}", conClient.Host + ":" + conClient.Port, conClient.Key)); } }
/// <summary> /// 释放用户 /// </summary> /// <param name="key"></param> private void DropConnUser(long key) { lock (ConnUserList) { if (ConnUserList.ContainsKey(key)) { var session = ConnUserList[key]; if (session.IsConnect && session.Client != null) { session.Client.Sock.Close(); } session.IsConnect = false; ConnUserList.TryRemove(key, out session); } } }