コード例 #1
0
ファイル: RoomClient.cs プロジェクト: alexxstst/RoomsSrv
        public RoomClient(IBaseSocketClient socketClient, IPool <byte[]> bytesPool, IPool <IRoomCommand> poolCommandPool,
                          IProtocolParser protocol)
        {
            if (bytesPool == null)
            {
                throw new ArgumentNullException(nameof(bytesPool));
            }

            if (poolCommandPool == null)
            {
                throw new ArgumentNullException(nameof(poolCommandPool));
            }

            if (protocol == null)
            {
                throw new ArgumentNullException(nameof(protocol));
            }

            if (socketClient == null)
            {
                throw new ArgumentNullException(nameof(socketClient));
            }

            _protocol    = protocol;
            _poolCommand = poolCommandPool;

            _baseSocketClient               = socketClient;
            _baseSocketClient.Disconnect   += OnDisconnect;
            _baseSocketClient.AfterSend    += (s, e) => bytesPool.Free(e.Buffer); //возвращаем данные в пул после отправки, для повторного использования
            _baseSocketClient.AfterReceive += OnAfterReceive;
        }
コード例 #2
0
ファイル: RemoteClient.cs プロジェクト: alexxstst/RoomsSrv
 public RemoteClient(IBaseSocketClient socketClient, IPool <byte[]> bytesPool, IPool <IRoomCommand> poolCommandPool, IProtocolParser protocol)
     : base(socketClient, bytesPool, poolCommandPool, protocol)
 {
 }