Class RoundRobinServerThread

Class RoundRobinServerThread

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----SleepingThread
                   |
                   +----RoundRobinServerThread

class RoundRobinServerThread
extends SleepingThread
The heart of the whole comunication system.

It has a RoundRobin structure in which the clients are organized. The thread accepts new clients from the ConnectServerThread in form of Sockets, transforms them into Player objects and then introduces them into the RoundRobin structure. The structure is parsed roundrobin like (deh ... :-) ) At each step a message is fetched from a inqueue, handled and then put into the appropriate outqueue(s). The real comunication between the queues and the remote client is done by special TCPIP handling threads per client. If at one step one of the queues of the current player are full then the corresponding player is in REAL trouble ( ;-) ) and will be shutdown (the server threads that took care of his communication), and eliminated from the RoundRobin structure. [SUBJECT TO CHANGE !!!] The server runs dynamically adjusting it's sleeping/step times according to the load. Currently there is a limit of 16000 players and 16000 groups. [SUBJECT TO CHANGE !!!]

Written: Radu Sion
Version: 1.16
Source: RoundRobinServerThread.java
See Also:
Player, ConnectServerThread, RoundRobin

Constructor Index

 o RoundRobinServerThread(ResourceHash)
Constructs a new RoundRobinServerThread.

Method Index

 o addNewPlayer(Socket, int)
The entrypoint in which new players are added.
 o dispatchMessage(Player, Message)
Takes a message from a given sender and tries to send it to the appropiate destination(s).
 o finalize()
 o run()

Constructors

 o RoundRobinServerThread
  public RoundRobinServerThread(ResourceHash rhash)
Constructs a new RoundRobinServerThread. No parameter checkings are performed.
Parameters:
rhash - ResourceHash to use in setting internal resources

Methods

 o addNewPlayer
  public synchronized void addNewPlayer(Socket sss,
                                        int priority) throws FullException
The entrypoint in which new players are added. (mainly from the ConnectServerThread)
(Attention, it's synchronized !!!)
Parameters:
sss - The new Socket to be used in adding to the RoundRobin structure
priority - A priority of this client relative to other clients (currently not used)
Throws: FullException
When there are already a maximum number of players arround.
 o dispatchMessage
  public int dispatchMessage(Player sender,
                             Message mess)
Takes a message from a given sender and tries to send it to the appropiate destination(s). It uses send() & broadcast() to do this. It returns the maximum out queue length found during the process or -1 if unable to send to any player.
 o run
  public void run()
Overrides:
run in class Thread
 o finalize
  protected void finalize()
Overrides:
finalize in class Object