Class Player

Class Player

java.lang.Object
   |
   +----Player

class Player
extends Object
A class wrapping a whole communication endpoint including In/Out queues etc.

There are the in/out queues, and two threads that take care of the client's Message queues.

Written: Radu Sion
Version: 0.28
Source: Player.java
See Also:
SimpleQueue, TCPIPReadThread, TCPIPWriteThread, Message, RoundRobinServerThread

Variable Index

 o Group
 o InMessageQueue
 o Number
 o OutMessageQueue
 o ReadThread
 o socket
 o WriteThread

Constructor Index

 o Player(Socket, int, int, int, int, int, int)
Creates a new Player object.

Method Index

 o down()
Stops the threads of this player and cleans up.
 o getGroup()
Gets the group number of the client.
 o setExitIfFullQueues(boolean, boolean)
Sets the behaviour of this player.
 o setGroup(int)
Sets the group number of the client.
 o testOk()
Tests if this player is ok, including threads etc.

Variables

 o socket
  public Socket socket
 o Number
  public int Number
 o Group
  public int Group
 o ReadThread
  public TCPIPReadThread ReadThread
 o WriteThread
  public TCPIPWriteThread WriteThread
 o OutMessageQueue
  public SimpleQueue OutMessageQueue
 o InMessageQueue
  public SimpleQueue InMessageQueue

Constructors

 o Player
  public Player(Socket sss,
                int outqueuelen,
                int inqueuelen,
                int player_nr,
                int group_nr,
                int rtsleep,
                int wtsleep)
Creates a new Player object. No parameter checkings performed.
Parameters:
sss - Socket identifying the net entity.
outqueuelen - Outgoing Message queue length
inqueuelen - Incoming Message queue length
player_nr - Client number used in identifying the client in the RoundRobinServerThread
group_nr - Group number used in identifying the client in the RoundRobinServerThread
rtsleep - ReadThread internal sleep delay
wtsleep - WriteThread internal sleep delay

Methods

 o testOk
  public boolean testOk()
Tests if this player is ok, including threads etc.
Returns:
True if ok, false otherwise
 o down
  public void down()
Stops the threads of this player and cleans up.
 o setExitIfFullQueues
  public void setExitIfFullQueues(boolean readq,
                                  boolean writeq)
Sets the behaviour of this player. If readq is true if the input queue becomes full then the player goes down, otherwise not. Idem. for writeq which controls the output queue
 o getGroup
  public synchronized int getGroup()
Gets the group number of the client.
 o setGroup
  public synchronized void setGroup(int group_nr)
Sets the group number of the client. (no checkings are done on parameters)
Parameters:
group_nr - The new group number to set