com.lyrisoft.chat.server.local
Class ConnectionHandlerLocal
java.lang.Object
|
+--com.lyrisoft.chat.server.local.ConnectionHandlerLocal
- All Implemented Interfaces:
- IConnectionHandler
- public class ConnectionHandlerLocal
- extends java.lang.Object
- implements IConnectionHandler
The keeper of the Socket on the client side.
Using deprecated JDK1.0.2 I/O methods on purpose, because this may be running in a crappy
browser.
This method spawns two threads: One for reading and one for writing. When new messages are read,
they are passed to the ChatServerLocal via it's incomingMessage() method
- See Also:
ChatServerLocal.incomingMessage(java.lang.String)
Field Summary |
protected java.io.DataInputStream |
_in
|
protected IConnectionListener |
_listener
|
protected java.io.PrintStream |
_out
|
protected com.lyrisoft.chat.server.local.ReaderThread |
_reader
|
protected java.net.Socket |
_socket
|
protected com.lyrisoft.chat.server.local.WriterThread |
_writer
|
Constructor Summary |
ConnectionHandlerLocal(java.net.Socket s)
Construct the ConnectionHandler and spawn the reader and writer threads. |
Method Summary |
void |
queueMessage(java.lang.String message)
Queue an outgoing message |
void |
sendImmediately(java.lang.String message)
Send a message immediately. |
void |
setListener(IConnectionListener listener)
Set the connection listener for this connection handler |
void |
shutdown(boolean notify)
Try to stop the threads gracefully, close the socket, then call connectionLost() on the
ChatServerLocal. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_out
protected java.io.PrintStream _out
_socket
protected java.net.Socket _socket
_in
protected java.io.DataInputStream _in
_listener
protected IConnectionListener _listener
_reader
protected com.lyrisoft.chat.server.local.ReaderThread _reader
_writer
protected com.lyrisoft.chat.server.local.WriterThread _writer
ConnectionHandlerLocal
public ConnectionHandlerLocal(java.net.Socket s)
throws java.io.IOException
- Construct the ConnectionHandler and spawn the reader and writer threads.
setListener
public void setListener(IConnectionListener listener)
- Description copied from interface:
IConnectionHandler
- Set the connection listener for this connection handler
- Specified by:
setListener
in interface IConnectionHandler
queueMessage
public void queueMessage(java.lang.String message)
- Queue an outgoing message
- Specified by:
queueMessage
in interface IConnectionHandler
sendImmediately
public void sendImmediately(java.lang.String message)
- Description copied from interface:
IConnectionHandler
- Send a message immediately.
- Specified by:
sendImmediately
in interface IConnectionHandler
shutdown
public void shutdown(boolean notify)
- Try to stop the threads gracefully, close the socket, then call connectionLost() on the
ChatServerLocal.
This method is typically called by the ReaderThread when it has detected the the
connection died.
- Specified by:
shutdown
in interface IConnectionHandler
- Following copied from interface:
com.lyrisoft.chat.IConnectionHandler
- Parameters:
notify
- to notify the ConnectionListener
Copyright © 2000-2002 Taso Lyristis