swpchat.server
Class ConnectedClientCollection

java.lang.Object
  |
  +--swpchat.server.ConnectedClientCollection

public class ConnectedClientCollection
extends java.lang.Object

This class saves all connected client, that means that these client have an controlProcotocolHandler instantiated.

Author:
Andre Brunner, Christian Stuellenberg, Marc Sturm

Field Summary
private  ChannelCollection channelCollection
           
private static java.lang.String CLS
           
private  ConnectionCollection controlCollection
           
private  java.util.Iterator iterator
           
private  java.util.HashMap memberServerMark
           
private  ConnectionCollection receiverCollection
           
private  ConnectionCollection senderCollection
           
 
Constructor Summary
ConnectedClientCollection(ChannelCollection channelCollection)
           
 
Method Summary
 void disconnectReceiverConnection(java.lang.String sessionKey)
           
 void disconnectSenderConnection(java.lang.String sessionKey)
           
 ClientConnection getClientConnection(java.lang.String sessionKey)
          used by other handlers for receiving actions
 ClientConnection getControlConnection(java.lang.String sessionKey)
           
private  java.lang.String getKeyFromClientConnection(ClientConnection myClientConnection)
           
 void removeConnection(java.lang.String strgNick)
          remove a ClientConnection from controlCollection
 void sendControlMessage(java.lang.String control, java.lang.String message1, java.lang.String message2, java.lang.String message3)
          sends to every ClientConnection from controlCollection a message that is handled by the ControlProtocolHandler
 void setReceiverConnection(java.lang.String sessionKey, ClientConnection connection)
           
 void setSenderConnection(java.lang.String sessionKey, ClientConnection connection)
           
 boolean tryToAddConnection(java.lang.String strgKey, ClientConnection clientConnection)
          Method tries to add ClientConnection to hashtable and is threadsave
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

private static final java.lang.String CLS

memberServerMark

private java.util.HashMap memberServerMark

controlCollection

private ConnectionCollection controlCollection

senderCollection

private ConnectionCollection senderCollection

receiverCollection

private ConnectionCollection receiverCollection

iterator

private java.util.Iterator iterator

channelCollection

private ChannelCollection channelCollection
Constructor Detail

ConnectedClientCollection

public ConnectedClientCollection(ChannelCollection channelCollection)
Method Detail

tryToAddConnection

public boolean tryToAddConnection(java.lang.String strgKey,
                                  ClientConnection clientConnection)
Method tries to add ClientConnection to hashtable and is threadsave
Parameters:
strgKey -  
connection -  
Returns:
true if clientConnection was added, else false

removeConnection

public void removeConnection(java.lang.String strgNick)
                      throws NoSuchMemberException
remove a ClientConnection from controlCollection
Parameters:
strgNick - the String specifying the sessionKey of the ClientConnection to remove

getControlConnection

public ClientConnection getControlConnection(java.lang.String sessionKey)
                                      throws NoSuchMemberException
Parameters:
sessionKey - speifying the sessionKey of the requested ClientConnection
Returns:
the connection that is specified by the sessionKey

sendControlMessage

public void sendControlMessage(java.lang.String control,
                               java.lang.String message1,
                               java.lang.String message2,
                               java.lang.String message3)
sends to every ClientConnection from controlCollection a message that is handled by the ControlProtocolHandler
Parameters:
control - is the {@java.lang.String} that identifys the command to do in the ControlProtocolHandler
message1 - is a {@java.lang.String} specifying part1 of message
message2 - is a {@java.lang.String} specifying part2 of message The method is threadsave, because otherwise the iterator will be used by several threads (gleichzeitig).

getKeyFromClientConnection

private java.lang.String getKeyFromClientConnection(ClientConnection myClientConnection)

setSenderConnection

public void setSenderConnection(java.lang.String sessionKey,
                                ClientConnection connection)

setReceiverConnection

public void setReceiverConnection(java.lang.String sessionKey,
                                  ClientConnection connection)

getClientConnection

public ClientConnection getClientConnection(java.lang.String sessionKey)
                                     throws NoSuchMemberException
used by other handlers for receiving actions
Parameters:
sessionKey - the sessionKey of the connection
Returns:
the ClientConnection linked with the unique sessionKey

disconnectSenderConnection

public void disconnectSenderConnection(java.lang.String sessionKey)

disconnectReceiverConnection

public void disconnectReceiverConnection(java.lang.String sessionKey)