public HabboMessenger GetUserMessenger(uint uid, bool loadData = false, UserData data = null) { if (userMessengers.ContainsKey(uid) && data == null) return (HabboMessenger)userMessengers[uid]; HabboMessenger result = new HabboMessenger(uid); Dictionary<uint, MessengerBuddy> friends = new Dictionary<uint, MessengerBuddy>(); if (loadData) { DataTable dFriends; using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor()) { dbClient.setQuery("SELECT users.id,users.username,users.motto,users.look,users.last_online,messenger_friendships.relationship " + "FROM users " + "JOIN messenger_friendships " + "ON users.id = messenger_friendships.sender " + "WHERE messenger_friendships.receiver = " + uid + " " + "UNION ALL " + "SELECT users.id,users.username,users.motto,users.look,users.last_online,messenger_friendships.relationship " + "FROM users " + "JOIN messenger_friendships " + "ON users.id = messenger_friendships.receiver " + "WHERE messenger_friendships.sender = " + uid); dFriends = dbClient.getTable(); } UInt32 friendID; foreach (DataRow dRow in dFriends.Rows) { friendID = (uint)dRow["id"]; if (friendID != uid && !friends.ContainsKey(friendID)) friends.Add(friendID, new MessengerBuddy(friendID, (string)dRow["username"], (string)dRow["look"], (string)dRow["motto"], (string)dRow["last_online"], (int)dRow["relationship"])); } result.Init(friends, new Dictionary<uint, MessengerRequest>()); } else if (data != null) { result.Init(data.friends, data.requests); } result.Init(new Dictionary<uint, MessengerBuddy>(), new Dictionary<uint, MessengerRequest>()); if (userMessengers.ContainsKey(uid)) userMessengers[uid] = result; else userMessengers.Add(uid, result); return result; }
public void setHandler(HabboMessenger messenger) { this.messenger = messenger; }
internal void Init(GameClient client, UserData data) { this.mClient = client; this.SubscriptionManager = new SubscriptionManager(Id, data); this.BadgeComponent = new BadgeComponent(Id, data); this.InventoryComponent = InventoryGlobal.GetInventory(Id, client, data); this.InventoryComponent.SetActiveState(client); this.AvatarEffectsInventoryComponent = new AvatarEffectsInventoryComponent(Id, client, data); this.quests = data.quests; this.chatMessageManager = new ChatMessageManager(); this.Messenger = new HabboMessenger(Id); this.Messenger.Init(data.friends, data.requests); this.SpectatorMode = false; this.Disconnected = false; this.UsersRooms = data.rooms; }