public void friendLoggedOut(User friend) { Console.WriteLine("Friend logged out" + friend); ChatUserEventArgs userArgs = new ChatUserEventArgs(ChatUserEvent.FriendLoggedOut, friend.Id); OnUserEvent(userArgs); }
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); }
public void userUpdate(object sender, ChatUserEventArgs e) { if (e.UserEventType == ChatUserEvent.FriendLoggedIn) { String friendId = e.Data.ToString(); //adauga modificarea pe threadul care a creat aplicatia Application.Invoke(delegate { friendsStore.AppendValues(friendId); }); Console.WriteLine("[ChatWindow] friendLoggedIn " + friendId); } if (e.UserEventType == ChatUserEvent.FriendLoggedOut) { String friendId = e.Data.ToString(); Console.WriteLine("[ChatWindow] friendLoggedOut " + friendId); TreeIter it; bool result = friendsStore.GetIterFirst(out it); for (int i = 0; i < friendsStore.IterNChildren(); i++) { String value = (string)friendsStore.GetValue(it, 0); Console.WriteLine("In for, am obtinut {0}", value); if (value == friendId) { Console.WriteLine("Found friend {0}", value); break; } friendsStore.IterNext(ref it); } //adauga modificarea pe threadul care a creat aplicatia Application.Invoke(delegate { friendsStore.Remove(ref it); }); } if (e.UserEventType == ChatUserEvent.NewMessage) { String messString = e.Data.ToString(); //adauga modificarea pe threadul care a creat aplicatia Application.Invoke(delegate { messageStore.AppendValues(messString); }); Console.WriteLine("[ChatWindow] messString " + messString); } }