Ejemplo n.º 1
0
        private void Server_OnPersonalPacketReceived(object sender, PersonalPacketEvents e)
        {
            if (e.Packet.Package is UserConnectionPacket ucp)
            {
                var notification = new ChatPacket
                {
                    Username  = "******",
                    Message   = "A new user has joined the chat",
                    UserColor = Colors.Purple.ToString()
                };

                if (Usernames.Keys.Contains(ucp.UserGuid))
                {
                    Usernames.Remove(ucp.UserGuid);
                }
                else
                {
                    Usernames.Add(ucp.UserGuid, ucp.Username);
                }

                ucp.Users = Usernames.Values.ToArray();

                Task.Run(() => _server.SendObjectToClients(ucp)).Wait();
                Thread.Sleep(500);
                Task.Run(() => _server.SendObjectToClients(notification)).Wait();
            }
            WriteOutput("Personal Packet Received");
        }
Ejemplo n.º 2
0
 private void Server_OnPersonalPacketSent(object sender, PersonalPacketEvents e)
 {
     WriteOutput("Personal Packet Sent");
 }