gecco.communication.server
Class RoleConnection

java.lang.Object
  |
  +--gecco.communication.server.RoleConnection

public class RoleConnection
extends Object

A class that represents the connection from the server to a specific role. So this class keeps track of all the clients that have joined as that specific role

Author:
Niklas Hallenfur

Field Summary
private  Vector clients
          Description of the Field
private  String role_name
          Description of the Field
private  Server server
          Description of the Field
 
Constructor Summary
RoleConnection(String role, Server server)
          Constructor for the RoleConnection object
 
Method Summary
 void add(ClientConnection c)
          adds a new client to this role
 int getAvailableId()
          returns the lowest nonnegative integer that is not used as an id by any client
 int getNumberOfClients()
          returns the number of clients connected to this role
 void remove(ClientConnectionHandler c)
          removes a client from this role
 void sendMessage(ServerMessage m)
          called by ClientAmbassodor to send a message to this role This method then distributes this message to all clients connected as this role
 String whoIsConnected()
          returns a string with the names of the clients connected to this role.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

clients

private Vector clients
Description of the Field

role_name

private String role_name
Description of the Field

server

private Server server
Description of the Field
Constructor Detail

RoleConnection

public RoleConnection(String role,
                      Server server)
Constructor for the RoleConnection object
Parameters:
role - Description of Parameter
server - Description of Parameter
Method Detail

getNumberOfClients

public int getNumberOfClients()
returns the number of clients connected to this role
Returns:
The NumberOfClients value

getAvailableId

public int getAvailableId()
returns the lowest nonnegative integer that is not used as an id by any client
Returns:
The AvailableId value

add

public void add(ClientConnection c)
adds a new client to this role
Parameters:
c - Description of Parameter

remove

public void remove(ClientConnectionHandler c)
removes a client from this role
Parameters:
c - Description of Parameter

whoIsConnected

public String whoIsConnected()
returns a string with the names of the clients connected to this role. The name is defined as the role immediately followed by the client's unique id
Returns:
Description of the Returned Value

sendMessage

public void sendMessage(ServerMessage m)
called by ClientAmbassodor to send a message to this role This method then distributes this message to all clients connected as this role
Parameters:
m - Description of Parameter