Class Message

java.lang.Object
marauroa.common.net.message.Message
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
MessageC2SAction, MessageC2SChooseCharacter, MessageC2SCreateAccount, MessageC2SCreateAccountWithToken, MessageC2SCreateCharacter, MessageC2SKeepAlive, MessageC2SLoginRequestKey, MessageC2SLoginWithToken, MessageC2SLogout, MessageC2SOutOfSync, MessageC2STransferACK, MessageC2SUpdateResponse, MessageP2SCreateAccount, MessageP2SCreateCharacter, MessageS2CCharacterList, MessageS2CChooseCharacterACK, MessageS2CChooseCharacterNACK, MessageS2CConnectNACK, MessageS2CCreateAccountACK, MessageS2CCreateAccountNACK, MessageS2CCreateCharacterACK, MessageS2CCreateCharacterNACK, MessageS2CInvalidMessage, MessageS2CLoginACK, MessageS2CLoginMessageNACK, MessageS2CLoginNACK, MessageS2CLoginSendKey, MessageS2CLogoutACK, MessageS2CLogoutNACK, MessageS2CPerception, MessageS2CServerInfo, MessageS2CTransfer, MessageS2CTransferREQ, MessageS2CUpdate, MessageSendByteArray

public class Message extends Object implements Serializable
Message is a class to represent all the kind of messages that are possible to exist in marauroa.
  • Field Details

    • CLIENTID_INVALID

      public static final int CLIENTID_INVALID
      Invalid client identificator constant
      See Also:
      Constant Field Values
    • type

      protected Message.MessageType type
      Type of the message
    • clientid

      protected int clientid
      Clientid of the player that generated the message
    • timestampMessage

      protected int timestampMessage
      Timestamp about when the message was created
    • protocolVersion

      protected int protocolVersion
      version of this message
    • channel

      protected Channel channel
      The socket channel that the message will use to be send or from where it was received
  • Constructor Details

    • Message

      protected Message(Message.MessageType type, Channel channel)
      Constructor with a TCP/IP source/destination of the message
      Parameters:
      type - the type of the message
      channel - The TCP/IP address associated to this message
  • Method Details

    • setChannel

      public void setChannel(Channel channel)
      Sets the TCP/IP source/destination of the message
      Parameters:
      channel - The TCP/IP socket associated to this message
    • getChannel

      public Channel getChannel()
      Returns the TCP/IP socket associatted with this message
      Returns:
      the TCP/IP socket associatted with this message
    • getAddress

      public InetAddress getAddress()
      Returns the address of the channel associated.
      Returns:
      the address of the channel associated.
    • getType

      public Message.MessageType getType()
      Returns the type of the message
      Returns:
      the type of the message
    • setClientID

      public void setClientID(int clientid)
      Set the clientID so that we can identify the client to which the message is target, as only IP is easy to Fake
      Parameters:
      clientid - a int that reprents the client id.
    • getClientID

      public int getClientID()
      Returns the clientID of the Message.
      Returns:
      the ClientID
    • getMessageTimestamp

      public int getMessageTimestamp()
      Returns the timestamp of the message. Usually milliseconds
      Returns:
      the timestamp of the message. Usually milliseconds
    • isSkippable

      public boolean isSkippable()
      may this method be skipped?
      Returns:
      true, if this method may be skipped; false otherwise.
    • isPerception

      public boolean isPerception()
      is this message a perception
      Returns:
      true, if this message is a perception; false otherwise
    • requiresPerception

      public boolean requiresPerception()
      does this message require a perception
      Returns:
      true, if this message requires a perception, false otherwise
    • getProtocolVersion

      public int getProtocolVersion()
      gets the protocol version
      Returns:
      protocol version
    • setProtocolVersion

      public void setProtocolVersion(int protocolVersion)
      sets the protocol version, limited to the max supported version
      Parameters:
      protocolVersion - protocol versoin
    • writeObject

      public void writeObject(OutputSerializer out) throws IOException
      Serialize the object into an ObjectOutput
      Specified by:
      writeObject in interface Serializable
      Parameters:
      out - the output serializer.
      Throws:
      IOException - if the serializations fails
    • writeToJson

      public void writeToJson(StringBuilder out)
      Serialize the object to json
      Parameters:
      out - output buffer
    • readObject

      public void readObject(InputSerializer in) throws IOException
      Serialize the object from an ObjectInput
      Specified by:
      readObject in interface Serializable
      Parameters:
      in - the input serializer
      Throws:
      IOException - if the serializations fails
    • readFromMap

      public void readFromMap(Map<String,​Object> in) throws IOException
      reads a message from a map
      Parameters:
      in - Map to read from
      Throws:
      IOException - if the serializations fails
    • internalToString

      protected void internalToString(StringBuilder sb)
      generates a list of attributes suitable to be used in toString()
      Parameters:
      sb - StringBuilder to append the attribute string to
    • toString

      public String toString()
      Overrides:
      toString in class Object