Package marauroa.common.net.message
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
Message is a class to represent all the kind of messages that are possible to
exist in marauroa.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected Channel
The socket channel that the message will use to be send or from where it was receivedprotected int
Clientid of the player that generated the messagestatic int
Invalid client identificator constantprotected int
version of this messageprotected int
Timestamp about when the message was createdprotected Message.MessageType
Type of the message -
Constructor Summary
ModifierConstructorDescriptionprotected
Message(Message.MessageType type, Channel channel)
Constructor with a TCP/IP source/destination of the message -
Method Summary
Modifier and TypeMethodDescriptionReturns the address of the channel associated.Returns the TCP/IP socket associatted with this messageint
Returns the clientID of the Message.int
Returns the timestamp of the message.int
gets the protocol versiongetType()
Returns the type of the messageprotected void
generates a list of attributes suitable to be used in toString()boolean
is this message a perceptionboolean
may this method be skipped?void
readFromMap(Map<String,Object> in)
reads a message from a mapvoid
Serialize the object from an ObjectInputboolean
does this message require a perceptionvoid
setChannel(Channel channel)
Sets the TCP/IP source/destination of the messagevoid
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 Fakevoid
setProtocolVersion(int protocolVersion)
sets the protocol version, limited to the max supported versiontoString()
void
writeObject(OutputSerializer out)
Serialize the object into an ObjectOutputvoid
writeToJson(StringBuilder out)
Serialize the object to json
-
Field Details
-
CLIENTID_INVALID
public static final int CLIENTID_INVALIDInvalid client identificator constant- See Also:
- Constant Field Values
-
type
Type of the message -
clientid
protected int clientidClientid of the player that generated the message -
timestampMessage
protected int timestampMessageTimestamp about when the message was created -
protocolVersion
protected int protocolVersionversion of this message -
channel
The socket channel that the message will use to be send or from where it was received
-
-
Constructor Details
-
Message
Constructor with a TCP/IP source/destination of the message- Parameters:
type
- the type of the messagechannel
- The TCP/IP address associated to this message
-
-
Method Details
-
setChannel
Sets the TCP/IP source/destination of the message- Parameters:
channel
- The TCP/IP socket associated to this message
-
getChannel
Returns the TCP/IP socket associatted with this message- Returns:
- the TCP/IP socket associatted with this message
-
getAddress
Returns the address of the channel associated.- Returns:
- the address of the channel associated.
-
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
Serialize the object into an ObjectOutput- Specified by:
writeObject
in interfaceSerializable
- Parameters:
out
- the output serializer.- Throws:
IOException
- if the serializations fails
-
writeToJson
Serialize the object to json- Parameters:
out
- output buffer
-
readObject
Serialize the object from an ObjectInput- Specified by:
readObject
in interfaceSerializable
- Parameters:
in
- the input serializer- Throws:
IOException
- if the serializations fails
-
readFromMap
reads a message from a map- Parameters:
in
- Map to read from- Throws:
IOException
- if the serializations fails
-
internalToString
generates a list of attributes suitable to be used in toString()- Parameters:
sb
- StringBuilder to append the attribute string to
-
toString
-