cluedo
Class CluedoPDU

java.lang.Object
  |
  +--cluedo.CluedoPDU

public class CluedoPDU
extends java.lang.Object
implements java.io.Serializable

Information exchange between clients and server is carried out by transmitting instances of this class via TCP. E.g. if a client wants to get a list of all available sessions from the server it creates an instance of SessionListRequestInfo. Instead of transmitting the info object directly to the server it is "wrapped" into an instance of CluedoPDU. The PDU is transmitted to the server. Beside from the Info object the PDU contains two more fields: The field senderId (see PlayerAddRequestInfo) itdentifies the sending client. The priority informs about the level of importance of the transported information. The protocol design of the interactive Cluedo game supports two priotrity levels (0 and 1). Packets of priority 0 must be transmitted. Packets of priority 1 are transmitted only if the packet queue of the sender is below a certain level, i.e. does not contain more than 10 packets to be transmitted.

Design goal: The distinction between PDU and Info objects allows us to design the communication between client and server independent from the transport protocol. Info objects can be interpreted as the "language" talked by client and server while PDU objects can be interpreted as the way of communication. This way it is possible to change the transport protocol without modifying the program logic of the application.

See Also:
CluedoPDU, Serialized Form

Field Summary
protected  CluedoInfo cluedoInfo
          The intrinsic information that is to be transported between client and server.
protected  int priority
          The priority of the PDU.
protected  int senderId
          Who sends this PDU? The senderid is the same unique id used by many inheritors of CluedoInfo to identify a certain player (playerId).
protected  int version
           
static int VERSION
           
 
Constructor Summary
CluedoPDU(int senderId, CluedoInfo cluedoInfo)
          This constructor sets the priority to zero (0)
CluedoPDU(int senderId, int priority, CluedoInfo cluedoInfo)
           
 
Method Summary
 CluedoInfo getCluedoInfo()
          Get the cluedoInfo object.
 int getPriority()
          Get the priority.
 int getSenderId()
          Get the senderId.
 int getVersion()
          Get the version.
 void setCluedoInfo(CluedoInfo cluedoInfo)
          Get the cluedoInfo object.
 void setPriority(int priority)
          Set the priority.
 void setSenderId(int senderId)
          Set the senderId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final int VERSION

version

protected int version

senderId

protected int senderId
Who sends this PDU? The senderid is the same unique id used by many inheritors of CluedoInfo to identify a certain player (playerId). The unique number is created by the server and transmitted to a client when it connects to the server (see PlayerAddRequestInfo).

priority

protected int priority
The priority of the PDU. The protocol design of the interactive Cluedo game supports two priotrity levels (0 and 1). Packets of priority 0 must be transmitted. Packets of priority 1 are transmitted only if the packet queue of the sender is below a certain level, i.e. does not contain more than 10 packets to be transmitted. (see cluedoInfo)

cluedoInfo

protected CluedoInfo cluedoInfo
The intrinsic information that is to be transported between client and server.
Constructor Detail

CluedoPDU

public CluedoPDU(int senderId,
                 CluedoInfo cluedoInfo)
This constructor sets the priority to zero (0)

CluedoPDU

public CluedoPDU(int senderId,
                 int priority,
                 CluedoInfo cluedoInfo)
Method Detail

getSenderId

public int getSenderId()
Get the senderId.

setSenderId

public void setSenderId(int senderId)
Set the senderId.

getPriority

public int getPriority()
Get the priority.

setPriority

public void setPriority(int priority)
Set the priority.

getCluedoInfo

public CluedoInfo getCluedoInfo()
Get the cluedoInfo object.

setCluedoInfo

public void setCluedoInfo(CluedoInfo cluedoInfo)
Get the cluedoInfo object.

getVersion

public int getVersion()
Get the version.