示例#1
0
        public void InitializePool(int maximumClients)//This method should be called before
        {
            // _userPool=new UserPool(maximumClients);
            _communicatorPool = new CommunicatorPool(maximumClients);
            _userPool         = new UserPool(maximumClients);
            BufferManager sendBuffer    = new BufferManager(maximumClients, BufferSize);
            BufferManager receiveBuffer = new BufferManager(maximumClients, BufferSize);

            for (int i = 0; i < maximumClients; i++)                          // Fill out the stack pool Initially
            {
                SocketAsyncEventArgs sendArg    = new SocketAsyncEventArgs(); // Create new Socket Pool for sending and receiving
                SocketAsyncEventArgs receiveArg = new SocketAsyncEventArgs();

                sendBuffer.SetBuffer(sendArg); // Set buffer for sendArg and receiveArg objects
                receiveBuffer.SetBuffer(receiveArg);

                _communicatorPool.Push(new Communicator(sendArg, receiveArg));
                _userPool.Push(new User(0));

                //_userPool.Push(new User(i));// put UserToken and UserID for the user initially
            }
        }
示例#2
0
 public Listener(CommunicatorPool communicatorPool)
 {
     CallBackonNewclient = null;//initialize delegate
     _communicatorPool   = communicatorPool;
 }