Example #1
0
        public ChatWindow(ClientServerMiddleman clientToServerMiddleman, string username)
        {
            InitializeComponent();

            _clientServerMiddleman = clientToServerMiddleman;
            clientToServerMiddleman.ConnectToChat(username);
            _username = username;

            var usersNames = clientToServerMiddleman.GetCurrentUsers()
                             .Select(x => new UserView {
                Name = x, Color = GetNextBrushFromColorCollection()
            })
                             .OrderBy(x => x.Name)
                             .ToList();

            usersNames.Where(x => x.Name == username).First().FontWeight = "Bold";

            ListBoxUsers.ItemsSource = usersNames.OrderBy(x => x.Name)
                                       .OrderByDescending(x => x.Name == _username).ToList();

            new Thread(() => clientToServerMiddleman.ReceiveFromServerAndCallbackOnSpecifiedDelegates(ReceiveIncomingChatMessage,
                                                                                                      ReceiveUserConnectedToChatNotification,
                                                                                                      ReceiveUserDisconnectedFromChatNotification))
            .Start();
        }
Example #2
0
        static void ConnectNewClient(string username)
        {
            new Thread(() =>
            {
                while (true)
                {
                    var clientMiddleman = new ClientServerMiddleman();
                    clientMiddleman.ConnectToServer(8931, "localhost");
                    clientMiddleman.ConnectToChat(username);

                    for (int j = 0; j < _sentences.Count; j++)
                    {
                        Thread.Sleep(new Random().Next(2000, 5000));
                        clientMiddleman.SendChatMessage(new OChat.Core.ClientSide.Models.ChatMessage {
                            Username = username, Content = _sentences[j]
                        });
                    }

                    clientMiddleman.DisconnectFromChatAndServer(username);

                    Thread.Sleep(new Random().Next(2000, 5000));
                }
            }).Start();
        }
Example #3
0
 public LoginWindow()
 {
     InitializeComponent();
     _clientServerMiddleman = new ClientServerMiddleman();
 }