public ClientMessageHandler(GameClient pSession) { mSession = pSession; mRequestHandlers = new RequestHandler[HIGHEST_MESSAGEID + 1]; Response = new ServerMessage(0); }
/// <summary> /// Destroys all the resources in the ClientMessageHandler. /// </summary> public void Destroy() { mSession = null; mRequestHandlers = null; Request = null; Response = null; }
public void Serialize(ServerMessage message) { message.AppendUInt32(mID); message.AppendString(mUsername); message.AppendBoolean(true); message.AppendBoolean(true); message.AppendBoolean(false); message.AppendString(mFigure); message.AppendBoolean(false); message.AppendString(mMotto); message.AppendString("1-1-1970"); }
public void Serialize(ServerMessage message) { message.AppendUInt32(mID); message.AppendBoolean(false); message.AppendString(mName); message.AppendString(mOwnerName); message.AppendInt32((int)mAccessType); message.AppendInt32((int)mVisitors); message.AppendInt32((int)mMaxVisitors); message.AppendString(mDescription); message.AppendBoolean(false); // All rights message.AppendBoolean(false); // Allow trading }
/// <summary> /// Adds activity points to this Habbo and notifies the client. /// </summary> /// <param name="amount">The amount of activity points to add.</param> public void AddActivityPoints(uint amount) { if (mHabbo != null) { // Add points mHabbo.ActivityPoints += amount; // Notify client ServerMessage notify = new ServerMessage(ResponseOpcodes.HabboActivityPointNotification); notify.AppendUInt32(mHabbo.ActivityPoints); notify.AppendUInt32(amount); this.GetConnection().SendMessage(notify); // Update user this.SaveUserObject(); } }
/// <summary> /// 34 - "@b" /// </summary> private void SendRoomInvite() { // TODO: check if this session is in room // Determine how many receivers int amount = Request.PopWiredInt32(); List<GameClient> receivers = new List<GameClient>(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); } }
/// <summary> /// 33 - "@a" /// </summary> 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); } } }
public void Serialize(ServerMessage message) { // I got bored here, sorry guys }
public void Serialize(ServerMessage message) { message.AppendString(mID.ToString()); message.AppendString(mUsername); message.AppendString(mFigure); message.AppendString(mGender.ToString()); message.AppendString(mMotto.ToString()); message.AppendBoolean(false); message.AppendString(""); message.AppendBoolean(false); message.AppendBoolean(false); message.AppendBoolean(false); message.AppendBoolean(false); }
private void TestClientConnections() { int interval = IonEnvironment.Configuration.TryParseInt32("projects.habbo.server.pinginterval"); while (true) { try { // Prepare PING data byte[] PINGDATA = new ServerMessage(ResponseOpcodes.Ping).GetBytes(); // "@r" // Gather timed out clients and reset ping status for in-time clients List<uint> timedOutClients = new List<uint>(); lock (mClients) { foreach (GameClient client in mClients.Values) { // Get current status and flip pong status if (client.PingOK) { client.PingOK = true; client.GetConnection().SendData(PINGDATA); } else { timedOutClients.Add(client.ID); } } // Stop the gathered timed out clients foreach (uint timedOutClientID in timedOutClients) { this.StopClient(timedOutClientID); } } // Sleep for 30 seconds and repeat! Thread.Sleep(interval); } catch (ThreadAbortException) { } // Nothing special! } }
public void Serialize(ServerMessage message) { }
public void SendMessage(ServerMessage message) { IonEnvironment.GetLog().WriteLine(" [" + mID + "] <-- " + message.Header + message.GetContentString()); SendData(message.GetBytes()); }
/// <summary> /// Sends a 'Notification from staff:' message. The message holds a given text. /// </summary> /// <param name="sText">The text to display in the message.</param> public void SendStaffMessage(string sText) { ServerMessage message = new ServerMessage(ResponseOpcodes.Mod); message.AppendString(sText); GetConnection().SendMessage(message); }
/// <summary> /// Reports a given error string to the client. /// </summary> /// <param name="sError">The error to report.</param> public void SendClientError(string sError) { ServerMessage message = new ServerMessage(ResponseOpcodes.GenericError); message.Append(sError); GetConnection().SendMessage(message); }
/// <summary> /// Sends the 'You are banned' message to the client. The message holds a given ban reason. /// </summary> /// <param name="sText">The text to display in the ban message.</param> public void SendBanMessage(string sText) { ServerMessage message = new ServerMessage(ResponseOpcodes.UserBanned); message.Append(sText); GetConnection().SendMessage(message); }