示例#1
0
        public TcpConnection(Socket socket, IProtocol protocol, IPacketRouter router, IBufferPool bufferPool)
            : base(router, protocol)
        {
            if (socket == null)
            {
                throw new ArgumentNullException(nameof(socket));
            }

            if (socket.ProtocolType != ProtocolType.Tcp)
            {
                throw new ArgumentException("Invalid socket protocol type. TCP required.", nameof(socket));
            }

            if (!socket.Connected)
            {
                throw new ArgumentException("Socket is not connected.", nameof(socket));
            }

            this.BaseSocket     = socket;
            this.RemoteEndPoint = socket.RemoteEndPoint;

            this.BufferPool = bufferPool;

            this.SilentSend = true;
        }
示例#2
0
        public ServerSession(TcpClient client, IPacketRouter packRouter = null, IPacketCompress packetCompress = null)
        {
            System.Diagnostics.Debug.Assert(client != null && packRouter != null);

            _tcpClient      = client;
            _packRouter     = packRouter ?? new ServerPacketRouter();
            _packetCompress = packetCompress ?? new PacketCompress();
        }
示例#3
0
        public ClientSession(string hostname, int port, IPacketRouter packetRouter, IPacketCompress packetCompress = null)
        {
            System.Diagnostics.Debug.Assert(packetRouter != null);

            _port           = port;
            _hostname       = hostname;
            _packRouter     = packetRouter;
            _packetCompress = packetCompress ?? new PacketCompress();
        }
示例#4
0
        public ServerTcpRouter(string ip, int port, IPacketRouter protocol)
        {
            UnityEngine.Debug.Assert(protocol != null && !string.IsNullOrEmpty(ip));

            _port     = port;
            _address  = IPAddress.Parse(ip);
            _protocol = protocol;
            _listener = new TcpListener(_address, _port);
        }
示例#5
0
 public ClientSession(SessionScope sessionScope, IPacketRouter packetRouter, IBufferPool <byte> bufferPool, ObjectPool <UncompressedPacket> uncompressedPacketObjectPool)
 {
     SessionScope = sessionScope;
     _tcpClient   = new TcpClient();
     _bufferPool  = bufferPool;
     _uncompressedPacketObjectPool = uncompressedPacketObjectPool;
     _packetRouter              = packetRouter;
     _outcomingPacketObserver   = new OutcomingPacketObserver(this);
     _outcomingPacketDispatcher = new ActionBlock <UncompressedPacket>(SendOutcomingPacket);
 }
示例#6
0
        public LibuvConnection(UvTcp socket, IProtocol protocol, IPacketRouter router, IBufferPool bufferPool)
            : base(router, protocol)
        {
            this.BaseSocket     = socket ?? throw new ArgumentNullException(nameof(socket));
            this.RemoteEndPoint = socket.GetPeerEndPoint();

            this.BufferPool = bufferPool;

            this.SilentSend = true;
        }
示例#7
0
 public VirtualConnection(IConnection baseConnection, IPacketRouter router, IProtocol protocol)
     : base(router, protocol)
 {
     this.BaseConnection = baseConnection;
 }
示例#8
0
 public Task SetPacketRouter(IPacketRouter packetRouter)
 {
     _packetRouter = packetRouter;
     return(Task.CompletedTask);
 }
示例#9
0
 public LoginHandler(IPacketSink packetSink, IPacketRouter packetRouter, IEventAggregator eventAggregator)
 {
     _packetSink      = packetSink;
     _packetRouter    = packetRouter;
     _eventAggregator = eventAggregator;
 }
示例#10
0
 protected Connection(IPacketRouter router, IProtocol protocol)
 {
     this.Router   = router;
     this.Protocol = protocol;
 }
示例#11
0
 public HandshakingHandler(IPacketSink packetSink, IPacketRouter packetRouter)
 {
     _packetSink   = packetSink;
     _packetRouter = packetRouter;
 }