Beispiel #1
0
        public void initialize(int capacity)
        {
            MaxConnectedClientLimit = capacity;

            socketListener = new SocketListener(capacity, (int)TCPCmdPacketSize.RECV_MAX_SIZE);
            socketListener.SocketClosed    += SocketClosed;
            socketListener.SocketConnected += SocketConnected;
            socketListener.SocketReceived  += SocketReceived;
            socketListener.SocketSended    += SocketSended;

            _tcpClientPool = TCPClientPool.getInstance();
            _tcpClientPool.initialize(100);
            _tcpLogClientPool = TCPClientPool.getLogInstance();
            _tcpLogClientPool.initialize(100);

            tcpInPacketPool = new TCPInPacketPool(capacity);
            /*tcpOutPacketPool = new TCPOutPacketPool(capacity);*/
            TCPOutPacketPool.getInstance().initialize(capacity);
            tcpOutPacketPool = TCPOutPacketPool.getInstance();
            dictInPackets    = new Dictionary <TMSKSocket, TCPInPacket>(capacity);
            tcpSessions      = new Dictionary <TMSKSocket, TCPSession>();
            TCPCmdDispatcher.getInstance().initialize();
#if UseTimer
            taskExecutor = new ScheduleExecutor(0);
#else
            taskExecutor = new ScheduleExecutor(1);
#endif
            taskExecutor.start();
        }
Beispiel #2
0
 public void initialize(int capacity)
 {
     this.MaxConnectedClientLimit         = capacity;
     this.socketListener                  = new SocketListener(capacity, 6144);
     this.socketListener.SocketClosed    += this.SocketClosed;
     this.socketListener.SocketConnected += this.SocketConnected;
     this.socketListener.SocketReceived  += this.SocketReceived;
     this.socketListener.SocketSended    += this.SocketSended;
     this._tcpClientPool                  = TCPClientPool.getInstance();
     this._tcpClientPool.initialize(100);
     this._tcpLogClientPool = TCPClientPool.getLogInstance();
     this._tcpLogClientPool.initialize(100);
     this.tcpInPacketPool = new TCPInPacketPool(capacity);
     TCPOutPacketPool.getInstance().initialize(capacity);
     this.tcpOutPacketPool = TCPOutPacketPool.getInstance();
     this.dictInPackets    = new Dictionary <TMSKSocket, TCPInPacket>(capacity);
     this.tcpSessions      = new Dictionary <TMSKSocket, TCPSession>();
     TCPCmdDispatcher.getInstance().initialize();
     this.taskExecutor = new ScheduleExecutor(0);
     this.taskExecutor.start();
 }