org.jogre.common.comm
Class CommGameMessage

java.lang.Object
  extended byorg.jogre.common.comm.CommGameMessage
All Implemented Interfaces:
ITransmittable
Direct Known Subclasses:
CommChatGame, CommDisconnect, CommError, CommGameConnect, CommInvite, CommMasterServerConnect, CommMasterServerMessage, CommNewTable, CommRequestData, CommTableMessage

public abstract class CommGameMessage
extends Object
implements ITransmittable

This is a message class which goes to a particular game such as chess, checkers etc. The extending class doesn't have to set the game - this is done behind the scenes. The gameID should be the game and version seperated with a colon e.g. chess:0.1

Version:
Alpha 0.2.3
Author:
Bob Marks

Field Summary
protected  int status
          Integer status of this comm message.
protected  String username
          Username of the person who sent this message.
protected  String usernameTo
          Username of the person who this is being sent to (if empty then no one).
static String XML_ATT_STATUS
          Type of message is used to determine which layer the message is for.
static String XML_ATT_USERNAME
           
static String XML_ATT_USERNAME_TO
           
 
Constructor Summary
protected CommGameMessage()
          Constructor with no parameters (no status).
protected CommGameMessage(int status)
          Constructor which takes a username and a status.
  CommGameMessage(int status, String username)
          Constructor which takes a status and a username to.
  CommGameMessage(String username)
          Constructor which only takes a username.
protected CommGameMessage(XMLElement message)
          Constructor which parses the XMLElement into class fields.
 
Method Summary
 XMLElement flatten(String name)
          Create a generic (nameless) XMLElement which sub classes can use.
 int getStatus()
          Return the status.
 String getUsername()
          Return the optional usernameTo variable.
 String getUsernameTo()
          Return the optional usernameTo variable.
 boolean isUsernameSet()
          Return true / false on the username being set.
 boolean isUsernameToSet()
          Return true / false on the usernameTo being set.
 void setUsername(String username)
          Set the optional uesrname variable.
 void setUsernameTo(String usernameTo)
          Set the optional usernameTo variable.
 String toString()
          Flatten a JOGRE message and indent it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jogre.common.comm.ITransmittable
flatten
 

Field Detail

status

protected int status
Integer status of this comm message.


username

protected String username
Username of the person who sent this message. This is usually required to be set if a client needs to know who sent a message and is set in the server.


usernameTo

protected String usernameTo
Username of the person who this is being sent to (if empty then no one).


XML_ATT_STATUS

public static final String XML_ATT_STATUS
Type of message is used to determine which layer the message is for.

See Also:
Constant Field Values

XML_ATT_USERNAME

public static final String XML_ATT_USERNAME
See Also:
Constant Field Values

XML_ATT_USERNAME_TO

public static final String XML_ATT_USERNAME_TO
See Also:
Constant Field Values
Constructor Detail

CommGameMessage

protected CommGameMessage()
Constructor with no parameters (no status).


CommGameMessage

protected CommGameMessage(int status)
Constructor which takes a username and a status.

Parameters:
status - A status

CommGameMessage

public CommGameMessage(String username)
Constructor which only takes a username.


CommGameMessage

public CommGameMessage(int status,
                       String username)
Constructor which takes a status and a username to.

Parameters:
status -

CommGameMessage

protected CommGameMessage(XMLElement message)
Constructor which parses the XMLElement into class fields.

Parameters:
message - Element to parse.
Method Detail

getStatus

public int getStatus()
Return the status.

Returns:
Status of user.

setUsername

public void setUsername(String username)
Set the optional uesrname variable.

Parameters:
username -

getUsername

public String getUsername()
Return the optional usernameTo variable.

Returns:
username

setUsernameTo

public void setUsernameTo(String usernameTo)
Set the optional usernameTo variable.

Parameters:
usernameTo -

getUsernameTo

public String getUsernameTo()
Return the optional usernameTo variable.

Returns:
username

isUsernameSet

public boolean isUsernameSet()
Return true / false on the username being set.

Returns:
True if username is set.

isUsernameToSet

public boolean isUsernameToSet()
Return true / false on the usernameTo being set.

Returns:
True if usernameTo is set.

toString

public String toString()
Flatten a JOGRE message and indent it.

See Also:
Object.toString()

flatten

public XMLElement flatten(String name)
Create a generic (nameless) XMLElement which sub classes can use.

Parameters:
name - Name of the XML element.
Returns:
XML version of this class.