Пример #1
0
        private void showOnConsoleUsers(Users client)
        {
            lock (lockDict)
            {
                if (connectedUsers.Count() > 1)
                {
                    foreach (KeyValuePair <string, Users> loginUser in connectedUsers)
                    {
                        if (loginUser.Key != client.UserId)
                        {
                            loginUser.Value.SendMessage($"{client.UserId} just joined the chat.");
                        }
                    }

                    client.SendMessage("Online users:");
                    foreach (KeyValuePair <string, Users> showCurrentOnline in connectedUsers)
                    {
                        if (showCurrentOnline.Key != client.UserId)
                        {
                            client.SendMessage($"-- {showCurrentOnline.Key}");
                        }
                    }
                }
                else
                {
                    client.SendMessage($"{client.UserId}, you're the only one logged in.");
                }
            }
        }