示例#1
0
        internal GameClient(GameProxy proxy, Socket socket)
        {
            Proxy         = proxy;
            EndPoint      = (IPEndPoint)socket.RemoteEndPoint;
            _clientSocket = socket;
            _serverSocket = new Socket(proxy.Info.RealEndPoint.AddressFamily,
                                       SocketType.Stream, ProtocolType.Tcp);

            void SetOptions(Socket socket)
            {
                socket.NoDelay        = true;
                socket.ReceiveTimeout = socket.SendTimeout = (int)proxy.Timeout.TotalMilliseconds;
            }

            SetOptions(_clientSocket);
            SetOptions(_serverSocket);

            _clientSendWriter = new GameBinaryWriter(_clientSendBuffer.GetArray());
            _serverSendWriter = new GameBinaryWriter(_serverSendBuffer.GetArray());

            var args = proxy.ArgsPool.Get();

            args.Completed     += OnConnect;
            args.RemoteEndPoint = Proxy.Info.RealEndPoint;

            proxy.AddClient(this);

            Connect(args);
        }
示例#2
0
        internal GameClient(GameProxy proxy, Socket socket)
        {
            Proxy         = proxy;
            EndPoint      = (IPEndPoint)socket.RemoteEndPoint;
            _clientSocket = socket;
            _serverSocket = new Socket(proxy.Info.RealEndPoint.AddressFamily,
                                       SocketType.Stream, ProtocolType.Tcp);

            SetOptions();

            var args = proxy.ArgsPool.Get();

            args.Completed     += OnConnect;
            args.RemoteEndPoint = Proxy.Info.RealEndPoint;

            proxy.AddClient(this);

            Connect(args);
        }