Пример #1
0
 public TcpConnectPool(UInt16 num = 8192)
 {
     Pools = new TcpConnect[num];
     for (UInt16 i = 0; i < num; i++)
     {
         Pools[i]             = new TcpConnect();
         Pools[i].IndexInPool = i;
         Pools[i].IsFree      = true;
         FreeObjects.Enqueue(Pools[i]);
     }
 }
Пример #2
0
 public void FreeConnect(TcpConnect conn)
 {
     lock (FreeObjects)
     {
         if (conn.IsFree == true)
         {
             return;
         }
         conn.IsFree = true;
         FreeObjects.Enqueue(conn);
     }
 }
Пример #3
0
 public void ProcessConnectPackages(TcpConnect conn)
 {
     NetCore.RecvData pkg;
     lock (conn.Packages)
     {
         if (conn.Packages.Count == 0)
         {
             return;
         }
         pkg = conn.Packages.Dequeue();
         RPCExecuter.Instance.ReceiveData(conn, pkg.PkgData, pkg.Length, pkg.RecvTime);
     }
     if (OnReceivePackage != null)
     {
         OnReceivePackage(conn, pkg);
     }
 }