com.lyrisoft.chat.server.remote
Class ServletConnectionHandler

java.lang.Object
  |
  +--com.lyrisoft.chat.server.remote.ServletConnectionHandler
All Implemented Interfaces:
IConnectionHandler

public class ServletConnectionHandler
extends java.lang.Object
implements IConnectionHandler

Special connection handler that handles "tunneled" connections to the chat. The ChatServlet delegates calls to it's service method to us: Upon a client's initial connection, the client is given a unique identifier, and the run method here is called. In the run method, we handle the output stream back to the client. On subsequent requests from the client, the client passes the unique identifier, and a message. That message is given to us in the incoming() method. This acts as the "input stream" from the client.


Field Summary
protected  java.util.LinkedList _queue
           
 
Constructor Summary
ServletConnectionHandler(TunnelServlet tunnelServlet, javax.servlet.http.HttpServletRequest request, java.lang.String id)
           
 
Method Summary
protected  void flush(java.io.PrintWriter out)
           
 void flushNewMessagesOrBlock(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 java.lang.String getHost()
           
 java.lang.String getId()
           
 void incoming(java.lang.String s)
           
 void queueMessage(java.lang.String message)
          Queue a message headed outbound
 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)
          Shutdown this connection listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_queue

protected java.util.LinkedList _queue
Constructor Detail

ServletConnectionHandler

public ServletConnectionHandler(TunnelServlet tunnelServlet,
                                javax.servlet.http.HttpServletRequest request,
                                java.lang.String id)
Method Detail

getId

public java.lang.String getId()

getHost

public java.lang.String getHost()

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

incoming

public void incoming(java.lang.String s)

flush

protected void flush(java.io.PrintWriter out)

flushNewMessagesOrBlock

public void flushNewMessagesOrBlock(javax.servlet.http.HttpServletRequest request,
                                    javax.servlet.http.HttpServletResponse response)
                             throws javax.servlet.ServletException,
                                    java.io.IOException

queueMessage

public void queueMessage(java.lang.String message)
Queue a message headed outbound
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)
Description copied from interface: IConnectionHandler
Shutdown this connection listener. The notify parameter indicates whether or not the client (ConnectionListener) should be notified of the shutdown. Basically, notify should only be false if the client itself called us.
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