public void friendLoggedOut(User friend)
        {
            Console.WriteLine("Friend logged out" + friend);
            ChatUserEventArgs userArgs = new ChatUserEventArgs(ChatUserEvent.FriendLoggedOut, friend.Id);

            OnUserEvent(userArgs);
        }
Beispiel #2
0
 public void userUpdate(object sender, ChatUserEventArgs e)
 {
     if (e.UserEventType == ChatUserEvent.FriendLoggedIn)
     {
         String friendId = e.Data.ToString();
         friendsData.Add(friendId);
         Console.WriteLine("[ChatWindow] friendLoggedIn " + friendId);
         friendList.BeginInvoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { friendList, friendsData });
         //   friendList.BeginInvoke((Action) delegate { friendList.DataSource = friendsData; });
     }
     if (e.UserEventType == ChatUserEvent.FriendLoggedOut)
     {
         String friendId = e.Data.ToString();
         friendsData.Remove(friendId);
         Console.WriteLine("[ChatWindow] friendLoggedOut " + friendId);
         friendList.BeginInvoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { friendList, friendsData });
     }
     if (e.UserEventType == ChatUserEvent.NewMessage)
     {
         String messString = e.Data.ToString();
         messageData.Add(messString);
         Console.WriteLine("[ChatWindow] messString " + messString);
         messageList.BeginInvoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { messageList, messageData });
     }
 }
        public void messageReceived(Message message)
        {
            String            mess     = "[" + message.Sender.Id + "]: " + message.Text;
            ChatUserEventArgs userArgs = new ChatUserEventArgs(ChatUserEvent.NewMessage, mess);

            Console.WriteLine("Message received");
            OnUserEvent(userArgs);
        }
 protected virtual void OnUserEvent(ChatUserEventArgs e)
 {
     if (updateEvent == null)
     {
         return;
     }
     updateEvent(this, e);
     Console.WriteLine("Update Event called");
 }
        public void sendMessage(string id, string txt)
        {
            //display the sent message on the user window
            String            mess     = "[" + currentUser.Id + "-->" + id + "]: " + txt;
            ChatUserEventArgs userArgs = new ChatUserEventArgs(ChatUserEvent.NewMessage, mess);

            OnUserEvent(userArgs);
            //sends the message to the server
            User    receiver = new User(id);
            Message message  = new Message(currentUser, receiver, txt);

            server.sendMessage(message);
        }