com.lyrisoft.chat.server.remote
Class ChatClient

java.lang.Object
  |
  +--com.lyrisoft.chat.server.remote.ChatClient
All Implemented Interfaces:
ICommands, IConnectionListener
Direct Known Subclasses:
FlashChatClient

public class ChatClient
extends java.lang.Object
implements IConnectionListener, ICommands

This is the representation of a Client, on the server side. All the IChatClient interface methods are implemented by constructing a message (with the help of CommandMakerRemote), and queuing it up to be sent to the client.

See Also:
CommandMakerRemote

Field Summary
protected  IConnectionHandler _connectionHandler
           
protected  ChatServer _server
           
protected  java.lang.String _userId
           
 
Fields inherited from interface com.lyrisoft.chat.ICommands
ACCESS_DENIED, ACK_KILL, ALREADY_SIGNED_ON, DELIMITER, EMOTE_TO_ROOM, EMOTE_TO_USER, ERROR, GET_ROOMS, GET_USERS_IN_ROOM, GET_USERS_ON_SERVER, HELP, HYPERLINK, IGNORE, INVALID_CHARACTER, INVITE, JOIN_ROOM, JOIN_ROOM_ACK, KICK, KILL, NO_INVITE, NO_SUCH_USER, OP, PART_ROOM, PART_ROOM_ACK, PING, PONG, REMOTE_CLIENT_MESSAGE, ROOM_ACCESS_DENIED, ROOM_DIFF, ROOM_MSG, ROOM_USER_DIFF, SAY_TO_ROOM, SAY_TO_USER, SHUTDOWN, SIGNOFF, SIGNON, SIGNON_ACK, STATS, UNIGNORE, UNINVITE, USER_DIFF, VERSION, WHOIS
 
Constructor Summary
ChatClient(ChatServer server, ServletConnectionHandler handler)
           
ChatClient(ChatServer server, java.net.Socket s)
           
 
Method Summary
 void ackJoinRoom(java.lang.String room)
          Construct and queue a message that will be sent back to the client
 void ackKill(java.lang.String victim)
           
 void ackPartRoom(java.lang.String room)
          Construct and queue a message that will be sent back to the client
 void ackSignon(java.lang.String myName)
          Construct and queue a message that will be sent back to the client
 void connectionLost()
          Construct and queue a message that will be sent back to the client
 IConnectionHandler createConnectionHandler(java.net.Socket s)
           
 void die()
          Do not call this method.
 void emote(java.lang.String user, java.lang.String room, java.lang.String message)
           
 void emoteFromUserPrivate(java.lang.String user, java.lang.String msg)
          Construct and queue a message that will be sent back to the client
 boolean equals(java.lang.Object o)
           
 void error(java.lang.String type, java.lang.String arg)
           
 void generalError(java.lang.String message)
          Construct and queue a message that will be sent back to the client
 void generalMessage(java.lang.String message)
          Construct and queue a message that will be sent back to the client
 void generalRoomMessage(java.lang.String room, java.lang.String message)
          Construct and queue a message that will be sent back to the client
 int getAccessLevel()
          Get the access level for this user
 java.lang.Object getAttribute(java.lang.String name)
           
 java.lang.String getClientVersion()
          Get the version of the client
 long getConnectionTime()
          Get the time (in milliseconds) when the user logged in
 java.lang.String getHost()
          Get the host the user is connected from
 long getIdle()
          Get the idle time (in milliseconds) for this user.
 java.lang.String getKey()
           
 long getLastServerPing()
           
 long getLastServerPong()
          used by the vulture to determine if the client has timed out
 ChatServer getServer()
           
 long getServerPingAvg()
           
 long getServerPingCount()
           
 boolean getTunneling()
           
 java.lang.String getUserId()
          Get the user's id
 void globalUserList(java.lang.String[] users)
          Construct and queue a message that will be sent back to the client
 int hashCode()
           
 void ignore(java.lang.String client)
           
 void incomingMessage(java.lang.String msg)
          from the IConnectionListener interface delegated to CommandProcessorRemote.process()
 void killed(java.lang.String killer, java.lang.String msg)
           
 void messageFromUser(java.lang.String user, java.lang.String room, java.lang.String msg)
          Construct and queue a message that will be sent back to the client
 void messageFromUserPrivate(java.lang.String user, java.lang.String msg)
          Construct and queue a message that will be sent back to the client
 void ping(java.lang.String user, java.lang.String arg)
          Construct and queue a message that will be sent back to the client
 void pong(java.lang.String user, java.lang.String arg)
          Construct and queue a message that will be sent back to the client
 void roomCreated(java.lang.String room)
           
 void roomDestroyed(java.lang.String room)
           
 void roomJoinError(java.lang.String s, java.lang.String room)
           
 void roomList(java.lang.String[] roomList)
          Construct and queue a message that will be sent back to the client
 void roomUserList(java.lang.String room, java.lang.String[] users)
          Construct and queue a message that will be sent back to the client
 void sendRaw(java.lang.String s)
           
 void setAccessLevel(int level)
          Set the access level for this user
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setClientVersion(java.lang.String version)
          Set the version of the client
 void setLastServerPing(long time)
           
 void setLastServerPong(long time)
           
 void setUserId(java.lang.String userId)
          Set the user's id
 void signOnError(java.lang.String s, java.lang.String user)
           
 void socketClosed()
          from the IConnectionListener interface call signOff on the server
 void unignore(java.lang.String client)
           
 void userJoinedRoom(java.lang.String user, java.lang.String room)
          Construct and queue a message that will be sent back to the client
 void userPartedRoom(java.lang.String user, java.lang.String room, boolean signOff)
          Construct and queue a message that will be sent back to the client
 void userSignOff(java.lang.String userId)
           
 void userSignOn(java.lang.String userId)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_connectionHandler

protected IConnectionHandler _connectionHandler

_server

protected ChatServer _server

_userId

protected java.lang.String _userId
Constructor Detail

ChatClient

public ChatClient(ChatServer server,
                  ServletConnectionHandler handler)

ChatClient

public ChatClient(ChatServer server,
                  java.net.Socket s)
           throws java.io.IOException
Method Detail

createConnectionHandler

public IConnectionHandler createConnectionHandler(java.net.Socket s)
                                           throws java.io.IOException

getTunneling

public boolean getTunneling()

ignore

public void ignore(java.lang.String client)

unignore

public void unignore(java.lang.String client)

getLastServerPong

public long getLastServerPong()
used by the vulture to determine if the client has timed out

getLastServerPing

public long getLastServerPing()

setLastServerPing

public void setLastServerPing(long time)

setLastServerPong

public void setLastServerPong(long time)

getServerPingAvg

public long getServerPingAvg()

getServerPingCount

public long getServerPingCount()

getIdle

public long getIdle()
Get the idle time (in milliseconds) for this user.

getConnectionTime

public long getConnectionTime()
Get the time (in milliseconds) when the user logged in

getAccessLevel

public int getAccessLevel()
Get the access level for this user
See Also:
IAuthenticator

getClientVersion

public java.lang.String getClientVersion()
Get the version of the client
Returns:
the version of the client

setClientVersion

public void setClientVersion(java.lang.String version)
Set the version of the client
Parameters:
version - the version

getHost

public java.lang.String getHost()
Get the host the user is connected from

setAccessLevel

public void setAccessLevel(int level)
Set the access level for this user

getUserId

public java.lang.String getUserId()
Get the user's id

setUserId

public void setUserId(java.lang.String userId)
Set the user's id

die

public void die()
Do not call this method. the proper way to kill a connection is by calling the SignOff method in ChatServer. Only ChatServer calls this.

getServer

public ChatServer getServer()

incomingMessage

public void incomingMessage(java.lang.String msg)
from the IConnectionListener interface delegated to CommandProcessorRemote.process()
Specified by:
incomingMessage in interface IConnectionListener
See Also:
CommandProcessorRemote.process(java.lang.String, com.lyrisoft.chat.server.remote.ChatClient)

socketClosed

public void socketClosed()
from the IConnectionListener interface call signOff on the server
Specified by:
socketClosed in interface IConnectionListener
See Also:
ChatServer.signOff(com.lyrisoft.chat.server.remote.ChatClient)

ackSignon

public void ackSignon(java.lang.String myName)
Construct and queue a message that will be sent back to the client

connectionLost

public void connectionLost()
Construct and queue a message that will be sent back to the client

ackJoinRoom

public void ackJoinRoom(java.lang.String room)
Construct and queue a message that will be sent back to the client

ackPartRoom

public void ackPartRoom(java.lang.String room)
Construct and queue a message that will be sent back to the client

messageFromUser

public void messageFromUser(java.lang.String user,
                            java.lang.String room,
                            java.lang.String msg)
Construct and queue a message that will be sent back to the client

messageFromUserPrivate

public void messageFromUserPrivate(java.lang.String user,
                                   java.lang.String msg)
Construct and queue a message that will be sent back to the client

emoteFromUserPrivate

public void emoteFromUserPrivate(java.lang.String user,
                                 java.lang.String msg)
Construct and queue a message that will be sent back to the client

roomList

public void roomList(java.lang.String[] roomList)
Construct and queue a message that will be sent back to the client

globalUserList

public void globalUserList(java.lang.String[] users)
Construct and queue a message that will be sent back to the client

roomUserList

public void roomUserList(java.lang.String room,
                         java.lang.String[] users)
Construct and queue a message that will be sent back to the client

userJoinedRoom

public void userJoinedRoom(java.lang.String user,
                           java.lang.String room)
Construct and queue a message that will be sent back to the client

userPartedRoom

public void userPartedRoom(java.lang.String user,
                           java.lang.String room,
                           boolean signOff)
Construct and queue a message that will be sent back to the client

generalError

public void generalError(java.lang.String message)
Construct and queue a message that will be sent back to the client

generalMessage

public void generalMessage(java.lang.String message)
Construct and queue a message that will be sent back to the client

generalRoomMessage

public void generalRoomMessage(java.lang.String room,
                               java.lang.String message)
Construct and queue a message that will be sent back to the client

ping

public void ping(java.lang.String user,
                 java.lang.String arg)
Construct and queue a message that will be sent back to the client

pong

public void pong(java.lang.String user,
                 java.lang.String arg)
Construct and queue a message that will be sent back to the client

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

roomJoinError

public void roomJoinError(java.lang.String s,
                          java.lang.String room)

signOnError

public void signOnError(java.lang.String s,
                        java.lang.String user)

error

public void error(java.lang.String type,
                  java.lang.String arg)

killed

public void killed(java.lang.String killer,
                   java.lang.String msg)

ackKill

public void ackKill(java.lang.String victim)

emote

public void emote(java.lang.String user,
                  java.lang.String room,
                  java.lang.String message)

sendRaw

public void sendRaw(java.lang.String s)

userSignOn

public void userSignOn(java.lang.String userId)

userSignOff

public void userSignOff(java.lang.String userId)

roomCreated

public void roomCreated(java.lang.String room)

roomDestroyed

public void roomDestroyed(java.lang.String room)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)

getAttribute

public java.lang.Object getAttribute(java.lang.String name)

getKey

public java.lang.String getKey()


Copyright © 2000-2002 Taso Lyristis