Пример #1
0
        private static void ClientDisconnected(SnooperSocketClient Client)
        {
            userProfile Profile = Clients.GetClientData(Client);

            if (Profile != null && Profile.LoggedIn)
            {
                Clients.Leave(Client);
                Client.Client.Close();
                Clients.SendAll(new ServerMessage()
                {
                    Message = $"User '{Profile.Username}' has left the chat (User Disconnected Unexpectedly).", Username = "******"
                }, null, "Messages");
            }
        }
Пример #2
0
        private static void LoginRequest(SnooperMessage message, SnooperSocketClient Client)
        {
            UserLoginData LData   = message.ReadObject <UserLoginData>();
            userProfile   Profile = Clients.GetClientData(Client);

            if (!Profile.LoggedIn)
            {
                Profile.LoggedIn = true;
                Profile.Username = LData.Username;
                Clients.SendAll(new ServerMessage()
                {
                    Message = $"User '{Profile.Username}' has joined the chat.", Username = "******"
                }, null, "Messages");
            }
        }
Пример #3
0
        private static void HandleNewMessage(SnooperMessage message, SnooperSocketClient Client)
        {
            userProfile Profile = Clients.GetClientData(Client);

            if (Profile.LoggedIn)
            {
                Clients.SendAll(new ServerMessage()
                {
                    Message = message.ReadObject <ClientMessage>().Message, Username = Profile.Username
                }, null, "Messages");
            }
            else
            {
            }
        }