/// <summary> /// Dispatch when someone came in. /// </summary> /// <param name="packet"></param> /// <param name="peer"></param> private void DispatchUserJoined(Packet packet, Peer peer) { UserJoinedReply reply = packet as UserJoinedReply; try { ChatRoom room = null; // Find the chatroom it goes. room = roomlist.Find(reply.Room); lock (room) { User user = new User(reply.User); // Add the user to the room. room.Users.Add(user); } if (room != null) { if (OnUserJoinedRoom != null) OnUserJoinedRoom(this, reply.User, room); } } catch (Exception) { } }
/// <summary> /// Send a private message to the user. /// </summary> /// <param name="message">Message to send.</param> public void Send(User user, String message) { if (message != "" && message != null) { MessageUserRequest request = new MessageUserRequest(); request.User = user.Name; request.Message = message; // Send packet Send(request); } }