|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--UserConnection
This class manages a users connections. It makes it possible to send messages to the user or to IRC and it handles relaying between them as well.
Field Summary | |
static char |
oop
Out of protocol delimiter. |
Constructor Summary | |
UserConnection(ChatServlet servlet,
User user,
java.io.ObjectOutputStream userOutputStream)
Creates the connection object. |
Method Summary | |
void |
close()
Used to close the connections to the IRC server and to the user. |
void |
connect(java.lang.String server,
int port)
Used to connect to the given IRC server. |
void |
execute(java.lang.String input)
Used to parse and execute a command from the Chatlet. |
void |
execute(java.lang.String command,
java.lang.String argument)
Used to execute specific commands sent by the Chatlet user. |
int |
getLocalPort()
Used to get the local port after a connection has been established. |
int |
getPort()
Used to get the port of the IRC server the user is connected to. |
java.lang.String |
getServer()
Used to get the IRC server the user is connected to. |
User |
getUser()
Used to get the user associated with this connection. |
boolean |
isConnected()
Used to check if this connection has been established. |
void |
keepAlive(long keepAliveDelay)
Used to keep a connection alive (fake keep-alive). |
java.lang.String |
parse(java.lang.String str)
Used to parse a String from the IRC server. |
void |
run()
Here we relay everything from the IRC server to the user after it has been parsed. |
void |
sendToIRC(java.lang.String str)
Used to send a String to the IRC server. |
void |
sendToUser(java.lang.String str)
Used to send a String to the user. |
static java.lang.String[] |
split(java.lang.String str,
java.lang.String pattern)
Used to split a string into parts according to a given pattern; |
java.lang.String |
toString()
Used to retrieve a String containing connection information. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char oop
Constructor Detail |
public UserConnection(ChatServlet servlet, User user, java.io.ObjectOutputStream userOutputStream)
servlet
- A reference to the ChatServlet.user
- The associated user.userOutputStream
- The output stream to the user.server
- The address of the IRC server.port
- The port of the IRC server.Method Detail |
public boolean isConnected()
public void connect(java.lang.String server, int port) throws java.io.IOException
server
- The address of the IRC server.port
- The port of the IRC server.public void keepAlive(long keepAliveDelay) throws java.io.IOException
public void sendToIRC(java.lang.String str) throws java.io.IOException
str
- The String to be sent.public void sendToUser(java.lang.String str) throws java.io.IOException
str
- The String to be sent.public void run()
run
in interface java.lang.Runnable
public static java.lang.String[] split(java.lang.String str, java.lang.String pattern)
str
- The string to be split.pattern
- The pattern to use when splitting,
where a * symbolises a part that
should be returned.public java.lang.String parse(java.lang.String str) throws java.io.IOException
str
- The String to be parsed.public void execute(java.lang.String input) throws java.io.IOException
input
- The input the user typed in the Chatlet.public void execute(java.lang.String command, java.lang.String argument) throws java.io.IOException
command
- The command issued by the user.argument
- The argument of the command, or null if none.public void close()
public java.lang.String getServer()
public int getPort()
public int getLocalPort()
public User getUser()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |