/// <summary> /// Adds the user in the given message if it isn'transfer already in the list /// of user for this model. If the user exists it updates the user /// information. /// Call this method when a User List Message (310) is /// received from the server. /// </summary> /// <param name="message"></param> public void OnUserListMessage(MessageEventArgs_302310 message) { if (!UserExists(message.UserId)) { var newUser = new User(message); userList.Add(newUser); if (ClientJoined != null) { ClientJoined(newUser); } } else { var u = GetUser(message.UserId); if (u != null) { u.UpdateUserInformation(message); } } }
public User(MessageEventArgs_302310 message) { SetUserInformation(message); Color = new NickColor(Nick).RGB; }
private void SetUserInformation(MessageEventArgs_302310 message) { admin = message.Admin; host = message.Host; icon = message.Icon; idle = message.Idle; image = message.Image; ip = message.Ip; login = message.Login; nick = message.Nick; status = message.Status; userId = message.UserId; }
/// <summary>Updates the user information with the information in the given message.</summary> /// <param name="message"></param> public void UpdateUserInformation(MessageEventArgs_302310 message) { if (message.UserId != userId) { throw new ApplicationException("The user from the given " + "message ('" + message + "') did not match the current " + "user ('" + this + "')"); } SetUserInformation(message); }
// 302 private void OnClientJoinEvent(object sender, int messageId, string messageName, string message) { if (ClientJoinEvent != null) { var words = SplitMessage(message); var chatId = int.Parse(words[0]); var userId = int.Parse(words[1]); var idle = Utility.ConvertIntToBool(int.Parse(words[2])); var admin = Utility.ConvertIntToBool(int.Parse(words[3])); var icon = int.Parse(words[4]); var nick = words[5]; var login = words[6]; var ip = IPAddress.Parse(words[7]); var host = words[8]; var status = words[9]; var image = Utility.Base64StringToBitmap(words[10]); var m = new MessageEventArgs_302310(messageId, messageName, chatId, userId, idle, admin, icon, nick, login, ip, host, status, image); ClientJoinEvent(m); } }
// 310 private void OnUserListEvent(object sender, int messageId, string messageName, string message) { if (UserListEvent != null) { var s = SplitMessage(message); int chatId = Convert.ToInt16(s[0]); int userId = Convert.ToInt16(s[1]); var idle = Convert.ToBoolean(Convert.ToInt16(s[2])); var admin = Convert.ToBoolean(Convert.ToInt16(s[3])); int icon = Convert.ToInt16(s[4]); var nick = s[5]; var login = s[6]; var ip = IPAddress.Parse(s[7]); var host = s[8]; var status = s[9]; var image = Utility.Base64StringToBitmap(s[10]); var m = new MessageEventArgs_302310(messageId, messageName, chatId, userId, idle, admin, icon, nick, login, ip, host, status, image); UserListEvent(m); } }