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

            OnUserEvent(userArgs);
        }
Example #2
0
        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);
        }
Example #3
0
 protected virtual void OnUserEvent(ChatUserEventArgs e)
 {
     if (updateEvent == null)
     {
         return;
     }
     updateEvent(this, e);
     Console.WriteLine("Update Event called");
 }
Example #4
0
        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);

            services.sendMessage(message);
        }
Example #5
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.Invoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { friendList, friendsData });
     }
     if (e.UserEventType == ChatUserEvent.FriendLoggedOut)
     {
         String friendId = e.Data.ToString();
         friendsData.Remove(friendId);
         Console.WriteLine("[ChatWindow] friendLoggedOut " + friendId);
         friendList.Invoke(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.Invoke(new UpdateListBoxCallback(this.updateListBox), new Object[] { messageList, messageData });
     }
 }