public void RemoveNotLoginUser(ref TcpClient MyTcpClientObj) { try { //Monitor.Enter(MyLoginUserList); string TempSocketInfor = MyTcpClientObj.Client.RemoteEndPoint.ToString(); for (int i = 0; i < MyLoginUserList.Count; i++) { if (MyLoginUserList[i].SocketInfor == TempSocketInfor) { //TempString = MyLoginUserList[i].SocketInfor; MyLoginUserList[i].MyReadWriteSocketChannel.MyTCPClient.Close(); MyLeaveLoginIDList.Add(MyLoginUserList[i].LoginID);//回收分配的通道Id MyLoginUserList.RemoveAt(i); LockConnectCount--; break; } } //------------------------------------------------------------------------------------------------- DisplayResultInfor(4, ""); //DisplayResultInfor(1, TempSocketInfor + ":因没有注册已断开连接!"); DisplayResultInfor(1, string.Format("当前锁端连接数[{0}]", LockConnectCount)); } catch (Exception InforEx) { DisplayResultInfor(1, string.Format("断开连接错误[{0}]", InforEx.Message)); } finally { ;//Monitor.Exit(MyLoginUserList); } }
public new void CRUDLoginUserListForDelete(ref TcpClient MyTcpClientObj) { try { Monitor.Enter(MyLoginUserList); //--1.-------------------------------------------------------------------------------------------- string TempMobileIDString = null; string TempLockIDString = null; //LoginUser BindedLoginUser = null; string InSocketInfor = MyTcpClientObj.Client.RemoteEndPoint.ToString(); //---1.--------------------------------------------------------------------------------------------- for (int i = 0; i < MyLoginUserList.Count; i++) { if (MyLoginUserList[i].SocketInfor == InSocketInfor) { MyLoginUserList[i].MyReadWriteSocketChannel.MyTCPClient.Close(); MyLeaveLoginIDList.Add(MyLoginUserList[i].LoginID);//回收分配的通道Id TempMobileIDString = MyLoginUserList[i].MobileID; TempLockIDString = MyLoginUserList[i].LockID; MyLoginUserList.RemoveAt(i); break; } } //--2.------------------------------------------------------------------------------------- for (int i = 0; i < MyLongFileReceiveProcList.Count; i++) { if (MyLongFileReceiveProcList[i].SocketInfor == InSocketInfor) { MyLongFileReceiveProcList.RemoveAt(i); break; } } if (TempMobileIDString != null) { OffLineResponseToMobile(TempMobileIDString, TempLockIDString); } //------------------------------------------------------------------------------------------------- DisplayResultInfor(4, ""); //DisplayResultInfor(0, MyTcpClientObj.Client.RemoteEndPoint.ToString() + ":已主动断开连接!"); LockConnectCount--; DisplayResultInfor(1, string.Format("当前锁端连接数[{0}]", LockConnectCount)); } catch (Exception InforEx) { DisplayResultInfor(1, string.Format("断开连接错误[{0}]", InforEx.Message)); } finally { Monitor.Exit(MyLoginUserList); } }