using System; using Duck.Net.Game.Protocol.Encoding; namespace Duck.Net.Game.Protocol.Messages { /// /// Represents a client>server message. /// public struct clientMessage { #region Declares /// /// 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 getParameter(int paramID) { return base64Encoding.getParameter(this.Content, paramID); } #endregion #region Properties /// /// The debug header of this message. /// public string debugHeader { get { return Debug.clientHeaders.getMessagesDebugHeader(this.ID); } } /// /// Returns the first parameter in this message as string, as indicated by the Base64 header. /// public string firstParameter { get { return base64Encoding.getFirstParameter(this.Content); } } /// /// Returns all parameters int this message as a string array, as indicated by the Base64 headers. /// public string[] Parameters { get { return base64Encoding.getParameters(this.Content); } } #endregion } }