Beispiel #1
0
 private HandleResult ClosePool(IntPtr connId, SocketOperation enOperation, int errorCode)
 {
     try
     {
         ClientInfo clientInfo = _server.GetExtra(connId);
         string.Format(" > [{0},OnAccept] -> PASS({1}:{2})", connId, clientInfo.IpAddress, clientInfo.Port);
         if (errorCode == 0)
         {
             WriteDeviceLog.WriteLog("Log\\" + _name + "\\Close客户端",
                                     string.Format(" > [{0},OnClose] -> On({1}:{2})", connId, clientInfo.IpAddress, clientInfo.Port),
                                     Guid.NewGuid().ToString());
         }
         else
         {
             WriteDeviceLog.WriteLog("Log\\" + _name + "\\Close客户端",
                                     string.Format(" > [{0},OnError] -> OP:{1},CODE:{2} -> On({3}:{4})", connId, enOperation,
                                                   errorCode, clientInfo.IpAddress, clientInfo.Port), Guid.NewGuid().ToString());
         }
         if (_server.RemoveExtra(connId) == false)
         {
             WriteDeviceLog.WriteLog("Log\\" + _name + "\\Close客户端",
                                     string.Format(" > [{0},OnClose] -> SetConnectionExtra({0}, null) fail -> On({1}:{2})", connId,
                                                   clientInfo.IpAddress, clientInfo.Port), Guid.NewGuid().ToString());
         }
         //连接断开删除客户端对象
         string dicConnIdValue;
         DicConnId.TryRemove(connId.ToString(), out dicConnIdValue);
         SpreadModel value = null;
         SpreadObject.TryRemove(connId.ToString(), out value);
         //服务信息
         InitServiceInfo(true);
         return(HandleResult.Ok);
     }
     catch (Exception ex)
     {
         WriteDeviceLog.WriteLog("Log\\" + _name + "\\Close客户端", ex.ToString(), Guid.NewGuid().ToString());
         return(HandleResult.Error);
     }
     finally
     {
         //InitMonitorService.AutoResetEvent.Set();
     }
 }