コード例 #1
0
        public static void HandleHandshakePacketServer(RUdpServer server, Packet packet, ClientInfo client)
        {
            client.IsActive = true;

            server.SendPacket(new HandshakePacket(), client);

            Console.WriteLine($@"Received connection from '{client.EndPoint}'!");
        }
コード例 #2
0
        public static void ChatPacketHandler(RUdpServer server, Packet packet, ClientInfo client)
        {
            // Console.WriteLine($"Connection from {client.EndPoint}");

            var chat = (ChatPacket)packet;

            Console.WriteLine($"Received chat message from {client.EndPoint}: {chat.Message}");

            foreach (ClientInfo c in server.Clients)
            {
                //  if (!c.EndPoint.Equals(client.EndPoint))
                server.SendPacket(chat, c);
            }
        }
コード例 #3
0
        public static void LoginPacketHandler(RUdpServer server, Packet packet, ClientInfo client)
        {
            // Console.WriteLine($"Connection from {client.EndPoint}");

            var login = (LoginPacket)packet;

            Console.WriteLine($"Logged in: {login.Username}");

            foreach (ClientInfo c in server.Clients)
            {
                // if (!c.EndPoint.Equals(client.EndPoint))
                server.SendPacket(login, c);
            }
        }