com.toremote.websocket.handler
Class AbstractHandler

java.lang.Object
  extended by com.toremote.websocket.handler.AbstractHandler
All Implemented Interfaces:
HandlerInterface
Direct Known Subclasses:
AbstractSessionHandler, ConfigHandler, ContainerHandler, GatewayHandler, LoginHandler, PlayHandler, ServerListHandler

public abstract class AbstractHandler
extends java.lang.Object
implements HandlerInterface


Field Summary
protected static int CLIENT_CLOSE
           
protected  java.util.Map<java.lang.String,java.lang.String> clientProperties
           
protected static char INFO_TAG
           
protected  SessionListener listener
           
protected  com.toremote.websocket.OutputInterface out
           
protected  java.util.Map<java.lang.String,java.lang.String> properties
           
protected  long startTime
           
 java.lang.String userAgent
           
 java.lang.String userIp
           
protected static char WARGIN_TAG
           
 
Fields inherited from interface com.toremote.websocket.handler.HandlerInterface
ARG_CLIENT_IP, ARG_HOST
 
Constructor Summary
AbstractHandler()
           
 
Method Summary
protected  com.toremote.license.License checkLicense()
           
 void exit()
          close the output
protected  java.lang.String getGatewayWebAddress()
           
 java.lang.String getSessionId()
           
protected  void handshake(java.lang.String action, java.util.Map<java.lang.String,java.lang.String> properties)
           
protected static boolean isTrue(java.lang.String s)
           
 void onClientDisconnected()
          invoked after client is disconnected by network issue etc.
 void onHandShake(java.lang.String path, java.lang.String protocol, java.lang.String cookie)
           
abstract  void onText(java.lang.String txt)
           
 void onTextReceived(java.lang.String txt)
          process client side text message
abstract  void processHandShake(java.lang.String action, java.util.Map<java.lang.String,java.lang.String> properties)
           
protected  void sendError(int code)
           
protected  void sendError(int code, java.lang.String msg)
           
protected  void sendError(int code, java.lang.String msg, java.lang.String callback)
           
 void setHandshakeListener(HandshakeListener l)
           
 void setOutput(com.toremote.websocket.OutputInterface output)
          setup output
 void setSessionId(java.lang.String id)
          set up session id for this session
 void showMessge(com.toremote.websocket.Message message)
           
 void showMessge(java.lang.String message)
           
 java.lang.String toJson()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.toremote.websocket.handler.HandlerInterface
onBinaryReceived
 

Field Detail

out

protected com.toremote.websocket.OutputInterface out

startTime

protected long startTime

listener

protected SessionListener listener

WARGIN_TAG

protected static final char WARGIN_TAG
See Also:
Constant Field Values

INFO_TAG

protected static final char INFO_TAG
See Also:
Constant Field Values

properties

protected java.util.Map<java.lang.String,java.lang.String> properties

clientProperties

protected java.util.Map<java.lang.String,java.lang.String> clientProperties

CLIENT_CLOSE

protected static final int CLIENT_CLOSE
See Also:
Constant Field Values

userIp

public java.lang.String userIp

userAgent

public java.lang.String userAgent
Constructor Detail

AbstractHandler

public AbstractHandler()
Method Detail

showMessge

public final void showMessge(com.toremote.websocket.Message message)
                      throws java.io.IOException
Throws:
java.io.IOException

showMessge

public final void showMessge(java.lang.String message)
                      throws java.io.IOException
Throws:
java.io.IOException

setHandshakeListener

public void setHandshakeListener(HandshakeListener l)

exit

public void exit()
Description copied from interface: HandlerInterface
close the output

Specified by:
exit in interface HandlerInterface

setOutput

public final void setOutput(com.toremote.websocket.OutputInterface output)
Description copied from interface: HandlerInterface
setup output

Specified by:
setOutput in interface HandlerInterface
See Also:
OutputInterface

onHandShake

public final void onHandShake(java.lang.String path,
                              java.lang.String protocol,
                              java.lang.String cookie)
                       throws java.lang.Exception
Specified by:
onHandShake in interface HandlerInterface
Parameters:
path - url path
protocol - websocket protocol, not used.
cookie - cookie from client side browser
Throws:
java.lang.Exception

setSessionId

public void setSessionId(java.lang.String id)
Description copied from interface: HandlerInterface
set up session id for this session

Specified by:
setSessionId in interface HandlerInterface

getSessionId

public java.lang.String getSessionId()

handshake

protected void handshake(java.lang.String action,
                         java.util.Map<java.lang.String,java.lang.String> properties)
                  throws java.lang.Exception
Throws:
java.lang.Exception

processHandShake

public abstract void processHandShake(java.lang.String action,
                                      java.util.Map<java.lang.String,java.lang.String> properties)
                               throws java.lang.Exception
Throws:
java.lang.Exception

toJson

public java.lang.String toJson()
Specified by:
toJson in interface HandlerInterface

sendError

protected void sendError(int code)
                  throws java.io.IOException
Throws:
java.io.IOException

sendError

protected void sendError(int code,
                         java.lang.String msg)
                  throws java.io.IOException
Throws:
java.io.IOException

sendError

protected void sendError(int code,
                         java.lang.String msg,
                         java.lang.String callback)
                  throws java.io.IOException
Throws:
java.io.IOException

onClientDisconnected

public void onClientDisconnected()
Description copied from interface: HandlerInterface
invoked after client is disconnected by network issue etc.

Specified by:
onClientDisconnected in interface HandlerInterface

isTrue

protected static final boolean isTrue(java.lang.String s)

checkLicense

protected com.toremote.license.License checkLicense()
                                             throws java.security.InvalidKeyException,
                                                    java.security.NoSuchAlgorithmException,
                                                    java.security.NoSuchProviderException,
                                                    java.security.spec.InvalidKeySpecException,
                                                    java.security.SignatureException,
                                                    java.io.IOException,
                                                    java.net.URISyntaxException,
                                                    com.toremote.license.LicenseExpiredException
Throws:
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
java.security.spec.InvalidKeySpecException
java.security.SignatureException
java.io.IOException
java.net.URISyntaxException
com.toremote.license.LicenseExpiredException

onTextReceived

public final void onTextReceived(java.lang.String txt)
                          throws java.lang.Exception
Description copied from interface: HandlerInterface
process client side text message

Specified by:
onTextReceived in interface HandlerInterface
Throws:
java.lang.Exception

onText

public abstract void onText(java.lang.String txt)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getGatewayWebAddress

protected java.lang.String getGatewayWebAddress()