using System; using System.Collections.Generic; using Ion.Net.Messages; using Ion.HabboHotel.Messenger; namespace Ion.HabboHotel.Client { public partial class ClientMessageHandler { /// /// 15 - "@O" /// private void FriendListUpdate() { } /// /// 33 - "@a" /// private void SendMsg() { uint buddyID = Request.PopWireduint(); string sText = Request.PopFixedString(); // Buddy in list? if (mSession.GetMessenger().GetBuddy(buddyID) != null) { // Buddy online? GameClient buddyClient = IonEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(buddyID); if (buddyClient == null) { Response.Initialize(ResponseOpcodes.InstantMessageError); // Opcode Response.AppendInt32(5); // Error code Response.AppendUInt32(mSession.GetHabbo().ID); SendResponse(); } else { ServerMessage notify = new ServerMessage(ResponseOpcodes.NewConsole); notify.AppendUInt32(mSession.GetHabbo().ID); notify.AppendString(sText); buddyClient.GetConnection().SendMessage(notify); } } } /// /// 34 - "@b" /// private void SendRoomInvite() { // TODO: check if this session is in room // Determine how many receivers int amount = Request.PopWiredInt32(); List receivers = new List(amount); // Get receivers for (int i = 0; i < amount; i++) { // User in buddy list? uint buddyID = Request.PopWireduint(); if (mSession.GetMessenger().GetBuddy(buddyID) != null) { // User online? GameClient buddyClient = IonEnvironment.GetHabboHotel().GetClients().GetClientOfHabbo(buddyID); if (buddyClient != null) { receivers.Add(buddyClient); } } } // Parse text string sText = Request.PopFixedString(); // Notify the receivers ServerMessage notify = new ServerMessage(ResponseOpcodes.RoomInvite); //... foreach (GameClient receiver in receivers) { receiver.GetConnection().SendMessage(notify); } } /// /// 37 - "@e" /// private void AcceptBuddy() { int amount = Request.PopWiredInt32(); for (int i = 0; i < amount; i++) { uint buddyID = Request.PopWireduint(); } } /// /// 38 - "@f" /// private void DeclineBuddy() { int amount = Request.PopWiredInt32(); for (int i = 0; i < amount; i++) { uint buddyID = Request.PopWireduint(); } } /// /// 39 - "@g" /// private void RequestBuddy() { } /// /// 40 - "@h" /// private void RemoveBuddy() { uint amount = Request.PopUInt32(); for (int i = 0; i < amount; i++) { uint buddyID = Request.PopWireduint(); if (mSession.GetMessenger().GetBuddy(buddyID) != null) { } } } /// /// 41 - "@i" /// private void HabboSearch() { // Parse search criteria string sCriteria = Request.PopFixedString(); uint ID = IonEnvironment.GetHabboHotel().GetHabbos().GetHabbo(sCriteria).ID; string Name = IonEnvironment.GetHabboHotel().GetHabbos().GetHabbo(sCriteria).Username; string Gender = IonEnvironment.GetHabboHotel().GetHabbos().GetHabbo(sCriteria).Gender.ToString(); string Motto = IonEnvironment.GetHabboHotel().GetHabbos().GetHabbo(sCriteria).Motto; string Figure = IonEnvironment.GetHabboHotel().GetHabbos().GetHabbo(sCriteria).Figure; Response.Initialize(128); //B@ Response.AppendString("MESSENGER"); Response.AppendUInt32(ID); Response.AppendString(Name); Response.Append(Gender); Response.AppendString(Motto); Response.AppendBoolean(false); //offline/online Response.AppendString(""); Response.AppendString("1/1/1337"); Response.AppendString(Figure); SendResponse(); } /// /// 233 - "Ci" /// private void GetBuddyRequests() { Response.Initialize(ResponseOpcodes.BuddyRequests); // "Dz" Response.AppendInt32(3); // Amount Response.AppendInt32(3); // Amount Response.AppendInt32(123456); // User ID Response.AppendString("HybridCore.NET"); Response.AppendString("5"); // Request ID Response.AppendInt32(123423); // User ID Response.AppendString("Jordan"); Response.AppendString("7"); // Request ID Response.AppendInt32(1234231337); // User ID Response.AppendString("Nillus"); Response.AppendString("12"); // Request ID SendResponse(); } /// /// 262 - "DF" /// private void FollowFriend() { } /// /// Registers the request handlers for the in-game messenger. ('Console') /// public void RegisterMessenger() { mRequestHandlers[15] = new RequestHandler(FriendListUpdate); mRequestHandlers[33] = new RequestHandler(SendMsg); mRequestHandlers[34] = new RequestHandler(SendRoomInvite); mRequestHandlers[37] = new RequestHandler(AcceptBuddy); mRequestHandlers[38] = new RequestHandler(DeclineBuddy); mRequestHandlers[39] = new RequestHandler(RequestBuddy); mRequestHandlers[40] = new RequestHandler(RemoveBuddy); mRequestHandlers[41] = new RequestHandler(HabboSearch); mRequestHandlers[233] = new RequestHandler(GetBuddyRequests); mRequestHandlers[262] = new RequestHandler(FollowFriend); } } }