Пример #1
0
        /// <summary>
        /// Handle the ping action sent from client.
        /// </summary>
        /// <param name="pingPacket">Ping packet received from client.</param>
        public void OnPing(PingPacket pingPacket)
        {
            Console.WriteLine("Ping Received: " + pingPacket.PingId);

            DataControl.Sender.SendSpeed = pingPacket.DownloadSpeed;

            Ping2Packet ping2Packet = new Ping2Packet(ClientId, pingPacket.PingId);

            Task.Run(async() => {
                await Conn.SendAsync(ping2Packet.Dgram, ClientIPEndPoint);
            });
        }
Пример #2
0
        /// <summary>
        /// Handle the ping2 action sent from server.
        /// </summary>
        /// <param name="ping2Packet"></param>
        public void OnPing2(Ping2Packet ping2Packet)
        {
            PingResponsed += 1;

            // First getting the clientId appointed by server
            if (ClientId == 0)
            {
                ClientId = ping2Packet.ClientId;
                Console.WriteLine("Client OK: " + ClientId);
            }

            Console.WriteLine("Ping2 Received: " + PingResponsed);
        }