private void HandleConnectionData(ref byte[] data) { int pos = 0; while (pos < data.Length) { try { if (data[0] == 60) { CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> Policy Request"); SendData(PolicyReplyData); CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] <-- Policy Sent"); Close(); return; } // Total length of message (without this): 3 Base64 bytes int messageLength = Base64Encoding.DecodeInt32(new[] {data[pos++], data[pos++], data[pos++]}); // ID of message: 2 Base64 bytes uint messageID = Base64Encoding.DecodeUInt32(new[] {data[pos++], data[pos++]}); // Data of message: (messageLength - 2) bytes byte[] content = new byte[messageLength - 2]; for (int i = 0; i < content.Length; i++) { content[i] = data[pos++]; } // Create message object IncomingMessage message = new IncomingMessage(messageID, content); if (Habbo.IsLoggedIn()) CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + Habbo.GetUsername() + "] --> " + message.GetHeader() + message.GetContentString()); else CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> " + message.GetHeader() + message.GetContentString()); // Handle message object bool unknown = true; if (_packetHandlers.GetLength(0) > messageID) { if (_packetHandlers[messageID, 3] != null) { lock (_packetHandlers[messageID, 3]) { _packetHandlers[messageID, 3].Invoke(Habbo, message); // Execute High Priority unknown = false; } } if (message.IsCancelled()) return; if (_packetHandlers[messageID, 2] != null) { lock (_packetHandlers[messageID, 2]) { _packetHandlers[messageID, 2].Invoke(Habbo, message); // Execute Low Priority unknown = false; } } if (message.IsCancelled()) return; if (_packetHandlers[messageID, 1] != null) { lock (_packetHandlers[messageID, 1]) { _packetHandlers[messageID, 1].Invoke(Habbo, message); // Execute Default Action unknown = false; } } if (_packetHandlers[messageID, 0] != null) { lock (_packetHandlers[messageID, 0]) { _packetHandlers[messageID, 0].Invoke(Habbo, message); // Execute Watchers unknown = false; } } } if (unknown) { CoreManager.ServerCore.GetStandardOut().PrintWarning("Packet " + messageID + " ('" + message.GetHeader() + "') unhandled!"); } } catch (IndexOutOfRangeException) // Bad formatting! { // TODO: Move this to IHI //IonEnvironment.GetHabboHotel().GetClients().StopClient(_id, 0); } catch (Exception ex) { CoreManager.ServerCore.GetStandardOut().PrintException(ex); } } }
private void Process_DYNAMIC(Habbo Sender, IncomingMessage Message) { lock (this.fPacketLogs) { this.fPacketLogs. Append("<div class='packet'>"). Append('['). Append(Message.GetID()). Append("] <u>"). Append(Message.GetHeader()). Append("</u>"). Append(Message.GetContentString()). Append("</div>"); } }
private void HandleConnectionData(ref byte[] data) { int pos = 0; while (pos < data.Length) { try { if (data[0] == 60) { CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> Policy Request"); SendData(PolicyReplyData); CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] <-- Policy Sent"); Close(); return; } // Total length of message (without this): 3 Base64 bytes int messageLength = Base64Encoding.DecodeInt32(new[] {data[pos++], data[pos++], data[pos++]}); // ID of message: 2 Base64 bytes uint messageID = Base64Encoding.DecodeUInt32(new[] {data[pos++], data[pos++]}); // Data of message: (messageLength - 2) bytes byte[] content = new byte[messageLength - 2]; for (int i = 0; i < content.Length; i++) { content[i] = data[pos++]; } // Create message object IncomingMessage message = new IncomingMessage(messageID, content); if (Habbo.IsLoggedIn()) CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + Habbo.GetUsername() + "] --> " + message.GetHeader() + message.GetContentString()); else CoreManager.ServerCore.GetStandardOut().PrintDebug("[" + _id + "] --> " + message.GetHeader() + message.GetContentString()); // Handle message object bool unknown = true; if (_packetHandlers.GetLength(0) > messageID) { if (_packetHandlers[messageID, 3] != null) { lock (_packetHandlers[messageID, 3]) { _packetHandlers[messageID, 3].Invoke(Habbo, message); // Execute High Priority unknown = false; } } if (message.IsCancelled()) return; if (_packetHandlers[messageID, 2] != null) { lock (_packetHandlers[messageID, 2]) { _packetHandlers[messageID, 2].Invoke(Habbo, message); // Execute Low Priority unknown = false; } } if (message.IsCancelled()) return; if (_packetHandlers[messageID, 1] != null) { lock (_packetHandlers[messageID, 1]) { _packetHandlers[messageID, 1].Invoke(Habbo, message); // Execute Default Action unknown = false; } } if (_packetHandlers[messageID, 0] != null) { lock (_packetHandlers[messageID, 0]) { _packetHandlers[messageID, 0].Invoke(Habbo, message); // Execute Watchers unknown = false; } } } if (unknown) { CoreManager.ServerCore.GetStandardOut().PrintWarning("Packet " + messageID + " ('" + message.GetHeader() + "') unhandled!"); } } catch (IndexOutOfRangeException) // Bad formatting! { // TODO: Move this to IHI //IonEnvironment.GetHabboHotel().GetClients().StopClient(_id, 0); } catch (Exception ex) { CoreManager.ServerCore.GetStandardOut().PrintException(ex); } } }
private void HandleConnectionData(ref byte[] data) { int pos = 0; while (pos < data.Length) { try { // Total length of message (without this): 3 Base64 bytes int messageLength = Base64Encoding.DecodeInt32(new byte[] { data[pos++], data[pos++], data[pos++] }); // ID of message: 2 Base64 bytes uint messageID = Base64Encoding.DecodeUInt32(new byte[] { data[pos++], data[pos++] }); // Data of message: (messageLength - 2) bytes byte[] Content = new byte[messageLength - 2]; for (int i = 0; i < Content.Length; i++) { Content[i] = data[pos++]; } // Create message object IncomingMessage message = new IncomingMessage(messageID, Content); if (this.mUser.IsLoggedIn()) { Core.GetStandardOut().PrintDebug("[" + this.mUser.GetUsername() + "] -- > " + message.Header + message.GetContentString()); } else { Core.GetStandardOut().PrintDebug("[No Name] -> " + message.Header + message.GetContentString()); } // Handle message object this.mPacketHandlers[messageID, 3].Invoke(message); // Execute High Priority if (message.IsCancelled()) { return; } this.mPacketHandlers[messageID, 2].Invoke(message); // Execute Low Priority if (message.IsCancelled()) { return; } this.mPacketHandlers[messageID, 1].Invoke(message); // Execute Default Action this.mPacketHandlers[messageID, 0].Invoke(message); // Execute Watchers } catch (IndexOutOfRangeException) // Bad formatting! { // TODO: Move this to IHI //IonEnvironment.GetHabboHotel().GetClients().StopClient(mID, 0); } catch (Exception ex) { Core.GetStandardOut().PrintError(ex.Message); } } }