예제 #1
0
        private void FigureOutConnectedClients()
        {
            try
            {
                List <ConnectedClient> clientlist = GetConnectedClients();
                ConnectedUsers.Clear();
                Connectedports.Clear();
                //int count = 0;
                foreach (ConnectedClient temp in clientlist)
                {
                    string user = temp.UserName;
                    this.ConnectedUsers.Add(user);
                    this.Connectedports.Add(temp.UrlAddress);
                }


                this.lbConnectedClients.Items.Clear();
                foreach (string client in this.ConnectedUsers)
                {
                    string display = (client == this.username ? "(ME) " : string.Empty) + client;

                    this.lbConnectedClients.Items.Add(display);
                }

                this.SetupSenderFactories();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
예제 #2
0
        private void Disonnect()
        {
            if (_tcpClient.Connected)
            {
                try
                {
                    _formatter.Serialize(_networkStream, new Message()
                    {
                        ChatMessage = Username, Type = Message.MessageType.Disconnect, Username = Username
                    });
                }
                catch (IOException)
                {
                    //Client closed connection
                }

                _networkStream.Close();
                _tcpClient.Close();
            }

            IsConnected = false;
            _tcpClient  = new TcpClient();

            ConnectedUsers.Clear();
            ChatMessages = String.Empty;

            _worker.CancelAsync();
        }
예제 #3
0
 private void ChannelOnUsersListReceived(object sender, EventArgs e)
 {
     ExecuteOnUiThread(() =>
     {
         var users = Channel.Users.Select(u => GetUserViewModel(u.User));
         ConnectedUsers.Clear();
         ConnectedUsers.AddRange(users);
     });
 }