Ejemplo n.º 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;
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 7
0
 public VirtualConnection(IConnection baseConnection, IPacketRouter router, IProtocol protocol)
     : base(router, protocol)
 {
     this.BaseConnection = baseConnection;
 }
Ejemplo n.º 8
0
 public Task SetPacketRouter(IPacketRouter packetRouter)
 {
     _packetRouter = packetRouter;
     return(Task.CompletedTask);
 }
Ejemplo n.º 9
0
 public LoginHandler(IPacketSink packetSink, IPacketRouter packetRouter, IEventAggregator eventAggregator)
 {
     _packetSink      = packetSink;
     _packetRouter    = packetRouter;
     _eventAggregator = eventAggregator;
 }
Ejemplo n.º 10
0
 protected Connection(IPacketRouter router, IProtocol protocol)
 {
     this.Router   = router;
     this.Protocol = protocol;
 }
Ejemplo n.º 11
0
 public HandshakingHandler(IPacketSink packetSink, IPacketRouter packetRouter)
 {
     _packetSink   = packetSink;
     _packetRouter = packetRouter;
 }