Пример #1
0
        public NetServerClient(ushort id, TcpClient tcpClient)
        {
            _id = id;

            // Also store endpoint with TCP address and TCP port
            _endPoint = (IPEndPoint)tcpClient.Client.RemoteEndPoint;

            _tcpNetClient = new TcpNetClient();
            _tcpNetClient.InitializeWithClient(tcpClient);
            _tcpNetClient.RegisterOnReceive(OnReceiveData);
        }
Пример #2
0
        public NetClient(PacketManager packetManager)
        {
            _packetManager = packetManager;

            _tcpNetClient = new TcpNetClient();
            _udpNetClient = new UdpNetClient();

            _tcpNetClient.RegisterOnConnect(OnConnect);
            _tcpNetClient.RegisterOnConnectFailed(OnConnectFailed);

            // Register the same function for both TCP and UDP receive callbacks
            _tcpNetClient.RegisterOnReceive(OnReceiveData);
            _udpNetClient.RegisterOnReceive(OnReceiveData);

            _udpUpdateManager = new UdpUpdateManager(_udpNetClient);
        }