swpchat.server
Class Channel

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

public class Channel
extends java.lang.Object

The Communicative context of a client in the server.

Author:
Hesse, Kensche

Field Summary
private  java.lang.String channelName
           
(package private) static java.lang.String CLS
           
private  java.util.Iterator iterator
           
private  java.util.HashMap markedMembers
           
private  ConnectionCollection receiverCollection
           
private  ConnectionCollection senderCollection
           
private  java.lang.String strRecPasswd
           
private  java.lang.String strSendPasswd
           
private  java.lang.String strTopic
           
 
Constructor Summary
Channel()
           
 
Method Summary
 boolean authorizeRec(java.lang.String passwd)
           
 boolean authorizeSend(java.lang.String passwd)
           
 boolean containsReceiver(java.lang.String sessionKey)
          tests iff receiver is contained in receiverCollection
 boolean containsSender(java.lang.String sessionKey)
          tests iff sender is contained in senderCollection
 void emotion(java.lang.String strFrom, java.lang.String target, java.lang.String emo)
          sends "emotion:strFrom:target:emotion" to every ClientConnection in receiverCollection
 java.lang.String getChannelName()
          returns the channel name of the actual channel
 java.lang.String getTopic()
          Returns topic
 boolean hasRecPasswd()
          Returns true if receiving is restricted
 boolean hasSendPasswd()
          Returns true if sending is restricted
 boolean isMemberMarked(java.lang.String sessionKey)
           
 void markMember(java.lang.String sessionKey)
           
 java.util.HashMap members()
           
 void play(java.lang.String strFrom, java.lang.String audioKey)
          sends "play:strFrom:audioKey" to every ClientConnection in receiverCollection
 void removeReceiverConnection(java.lang.String strgNick)
          remove a ClientConnection from receiverCollection
 void removeSenderConnection(java.lang.String strgNick)
          remove a ClientConnection from senderCollection
 void send(java.lang.String strFrom, java.lang.String strMessage)
          send strFrom and strMessage to every ClientConnection in receiverCollection
 void setChannelName(java.lang.String name)
          sets the channel name for the actual channel
 void setRecPasswd(java.lang.String passwd)
           
 void setSendPasswd(java.lang.String passwd)
           
 void setTopic(java.lang.String topic)
          Sets topic for a channel
 void ship(java.lang.String strFrom, java.lang.String receiver, boolean status)
          ship not really implemented yet
 void topicChanged(java.lang.String strFrom, java.lang.String topic)
          sends "topicchanged:strFrom:topic" to every ClientConnection in receiverCollection
 boolean tryToAddReceiverConnection(java.lang.String strgKey, ClientConnection clientConnection)
          Method tries to add ClientConnection to hashtable and is threadsave
 boolean tryToAddSenderConnection(java.lang.String strgNick, ClientConnection clientConnection)
          Try to add a ClientConnection with the key specified in String to senderCollection.
 void whisper(java.lang.String receiverSessionKey, java.lang.String SenderNickName, java.lang.String Msg)
          sends "whisper:receiverSessionKey:SenderNickName:Msg" to the ClientConnection corresponding to the receiverSessionKey
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

CLS

static final java.lang.String CLS

markedMembers

private java.util.HashMap markedMembers

receiverCollection

private ConnectionCollection receiverCollection

senderCollection

private ConnectionCollection senderCollection

iterator

private java.util.Iterator iterator

channelName

private java.lang.String channelName

strTopic

private java.lang.String strTopic

strSendPasswd

private java.lang.String strSendPasswd

strRecPasswd

private java.lang.String strRecPasswd
Constructor Detail

Channel

public Channel()
Method Detail

setTopic

public void setTopic(java.lang.String topic)
Sets topic for a channel
Parameters:
topic - the new topic

hasSendPasswd

public boolean hasSendPasswd()
Returns true if sending is restricted

hasRecPasswd

public boolean hasRecPasswd()
Returns true if receiving is restricted

getTopic

public java.lang.String getTopic()
Returns topic

setSendPasswd

public void setSendPasswd(java.lang.String passwd)

setRecPasswd

public void setRecPasswd(java.lang.String passwd)

authorizeSend

public boolean authorizeSend(java.lang.String passwd)

authorizeRec

public boolean authorizeRec(java.lang.String passwd)

markMember

public void markMember(java.lang.String sessionKey)

isMemberMarked

public boolean isMemberMarked(java.lang.String sessionKey)

tryToAddReceiverConnection

public boolean tryToAddReceiverConnection(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

tryToAddSenderConnection

public boolean tryToAddSenderConnection(java.lang.String strgNick,
                                        ClientConnection clientConnection)
Try to add a ClientConnection with the key specified in String to senderCollection. The
Parameters:
strgNick - the String specifying the nickname
clientConnection - the ClientConnection to add
Returns:
true if clientConnection was added, else false

removeReceiverConnection

public void removeReceiverConnection(java.lang.String strgNick)
                              throws NoSuchMemberException
remove a ClientConnection from receiverCollection
Parameters:
strgNick - the String specifying the nickname of the ClientConnection to remove

removeSenderConnection

public void removeSenderConnection(java.lang.String strgNick)
                            throws NoSuchMemberException
remove a ClientConnection from senderCollection
Parameters:
strgNick - the String specifying the nickname of the ClientConnection to remove

send

public void send(java.lang.String strFrom,
                 java.lang.String strMessage)
send strFrom and strMessage to every ClientConnection in receiverCollection
Parameters:
strFrom - String specifying the ClientConnection from where the message was sent.
strMessage - String specifying the message to send

members

public java.util.HashMap members()

topicChanged

public void topicChanged(java.lang.String strFrom,
                         java.lang.String topic)
sends "topicchanged:strFrom:topic" to every ClientConnection in receiverCollection
Parameters:
strFrom - String specifying the ClientConnection from where the "settopic" was sent.
topic - String specifying the topic to send

play

public void play(java.lang.String strFrom,
                 java.lang.String audioKey)
sends "play:strFrom:audioKey" to every ClientConnection in receiverCollection
Parameters:
strFrom - String specifying the ClientConnection from where the "play" was sent.
audioKey - String specifying the audioKey to send

whisper

public void whisper(java.lang.String receiverSessionKey,
                    java.lang.String SenderNickName,
                    java.lang.String Msg)
             throws NoSuchMemberException
sends "whisper:receiverSessionKey:SenderNickName:Msg" to the ClientConnection corresponding to the receiverSessionKey
Parameters:
receiverSessionKey - String specifying the ClientConnection ti which the whisper is sent
SenderNickName - String specifying the ClientConnection the whisper was sent from
Msg - String the actually message to be whispered
Throws:
NoSuchMemberException - thrown if receiver is not in the channel

emotion

public void emotion(java.lang.String strFrom,
                    java.lang.String target,
                    java.lang.String emo)
sends "emotion:strFrom:target:emotion" to every ClientConnection in receiverCollection
Parameters:
strFrom - String specifying the ClientConnection from where the "play" was sent.
target - String specifying target of the emotion
emotion - String specifying the emotion

ship

public void ship(java.lang.String strFrom,
                 java.lang.String receiver,
                 boolean status)
ship not really implemented yet

setChannelName

public void setChannelName(java.lang.String name)
sets the channel name for the actual channel
Parameters:
name - String specifying the name of this channel

getChannelName

public java.lang.String getChannelName()
returns the channel name of the actual channel
Returns:
String with the actual name of this channel

containsSender

public boolean containsSender(java.lang.String sessionKey)
tests iff sender is contained in senderCollection
Parameters:
{@link - java.lang.String} identifying the searched Key
Returns:
a boolean value of true, iff sessionKey is contained in senderCollection

containsReceiver

public boolean containsReceiver(java.lang.String sessionKey)
tests iff receiver is contained in receiverCollection
Parameters:
{@link - java.lang.String} identifying the searched Key
Returns:
a boolean value of true, iff sessionKey is contained in receiverCollection