using System;
using System.Collections.Generic;
using Woodpecker.Specialized.Encoding;
namespace Woodpecker.Net.Game.Messages
{
///
/// Represents a client>server message for the Habbo FUSE protocol.
///
public class clientMessage
{
#region Fields
///
/// The message ID of this message.
///
public readonly int ID;
///
/// The content of this message.
///
public string Content;
#endregion
#region Constructors
public clientMessage(string Data)
{
this.ID = base64Encoding.Decode(Data.Substring(0, 2));
this.Content = Data.Substring(2);
}
#endregion
#region Methods
///
/// Retrieves a certain parameter from the message's content. If the parameter is not found or any errors occur, then "" is returned.
///
/// The ID of the parameter to retrieve.
public string getStructuredParameter(int paramID)
{
return base64Encoding.getStructuredParameter(this.Content, paramID);
}
///
/// Searches through the message content for the xxth parameter and returns it. If not found, then "" is returned.
///
/// The parameter to look for, 0 will return the first parameter, 1 the second, 2 the third etc.
public string getParameter(int parameterLocation)
{
return base64Encoding.getParameter(this.Content, parameterLocation);
}
///
/// Wire decodes the message content and returns it as an integer.
///
///
public int getNextWiredParameter()
{
try
{
return wireEncoding.Decode(ref this.Content);
}
catch { return 0; }
}
///
/// Decodes the whole message content (assumed that it's a wired string of encoded numbers) to an integer array. An empty array is returned on errors.
///
public int[] getWiredParameters()
{
return wireEncoding.decodeWire(this.Content);
}
public string[] getMixedParameters()
{
return mixedEncoding.getMixedParameters(this.Content);
}
public int[] getNumericMixedParameters()
{
return mixedEncoding.getMixedParametersAsIntegers(this.Content);
}
#endregion
#region Properties
///
/// Returns the ID of this message encoded in Base64.
///
public string encodedID
{
get { return base64Encoding.Encode(this.ID); }
}
///
/// The method name of this message.
///
public string methodName
{
get { return clientMessageTargetMethodNames.getMessageTargetMethodName(this.ID); }
}
///
/// Returns all parameters in this message as a string array, as indicated by the Base64 headers.
///
public string[] Parameters
{
get { return base64Encoding.getParameters(this.Content); }
}
#endregion
}
}