com.toremote.gateway.client
Class ClientManager

java.lang.Object
  extended by com.toremote.gateway.client.ClientManager
All Implemented Interfaces:
SessionReaderInterface, SessionWriterInterface

public class ClientManager
extends java.lang.Object
implements SessionWriterInterface

Used to manage session on gateway, you can use ClientManager.getInstance() to get the instance and manage sessions on gateway.


Field Summary
(package private)  java.util.Map<java.lang.String,com.toremote.websocket.handler.AbstractSessionHandler> clients
           
(package private)  java.util.List<ThumbnailListenerInteface> thumbnailListeners
           
 
Method Summary
 void addClient(java.lang.String id, com.toremote.websocket.handler.AbstractSessionHandler handler)
          add session, session implements AbstractSessionHandler will be automatically added
 void addThumbnailListener(ThumbnailListenerInteface tli)
          used for getting thumbnails from client side.
 HandlerInterface getHandler(java.lang.String id)
           
 int getId()
           
static ClientManager getInstance()
           
 java.util.Set<java.lang.Integer> getNumericIds()
           
 java.lang.String getSessionIdByNumericId(int numericId)
           
 java.util.Set<java.lang.String> getSessionIds()
           
 SessionInformation getSessionInfo(int numericId)
           
 SessionInformation getSessionInfo(java.lang.String id)
           
 int getTotalClients()
           
 void processTumbnail(java.lang.String sessionId, java.lang.String thumbnail)
           
 void removeClient(java.lang.String id)
          remove session, this doesn't close the session.
 void removeThumbnailListener(ThumbnailListenerInteface tli)
          remove thumbnail listener
 boolean terminateSession(java.lang.String id)
          Close the session
 java.lang.String toJson(java.lang.String callback)
           
 java.lang.String toJsonTable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clients

java.util.Map<java.lang.String,com.toremote.websocket.handler.AbstractSessionHandler> clients

thumbnailListeners

java.util.List<ThumbnailListenerInteface> thumbnailListeners
Method Detail

getId

public int getId()
Returns:
generate a 9 digits numeric id

addClient

public void addClient(java.lang.String id,
                      com.toremote.websocket.handler.AbstractSessionHandler handler)
               throws java.lang.Exception
add session, session implements AbstractSessionHandler will be automatically added

Parameters:
id -
handler -
Throws:
java.lang.Exception

removeClient

public void removeClient(java.lang.String id)
remove session, this doesn't close the session. session implements AbstractSessionHandler will be automatically removed after the session was closed

Parameters:
id -

getInstance

public static final ClientManager getInstance()
Returns:
ClientManager instance

getHandler

public HandlerInterface getHandler(java.lang.String id)
Parameters:
id -
Returns:
handled with the id was added before

getTotalClients

public int getTotalClients()
Returns:
count of sessions on the gateway

toJson

public java.lang.String toJson(java.lang.String callback)
Parameters:
callback -
Returns:
JSON string for all sessions.

toJsonTable

public java.lang.String toJsonTable()
Returns:
json table which is used by config.html

getSessionIds

public java.util.Set<java.lang.String> getSessionIds()
Specified by:
getSessionIds in interface SessionReaderInterface
Returns:
all session ids (GUID)

getNumericIds

public java.util.Set<java.lang.Integer> getNumericIds()
Specified by:
getNumericIds in interface SessionReaderInterface
Returns:
all numeric ids of sessions

getSessionInfo

public SessionInformation getSessionInfo(java.lang.String id)
Specified by:
getSessionInfo in interface SessionReaderInterface
Parameters:
id - GUID
Returns:
SessionInformation
See Also:
SessionInformation

getSessionInfo

public SessionInformation getSessionInfo(int numericId)
Specified by:
getSessionInfo in interface SessionReaderInterface
Returns:
SessionInformation
See Also:
SessionInformation

terminateSession

public boolean terminateSession(java.lang.String id)
Description copied from interface: SessionWriterInterface
Close the session

Specified by:
terminateSession in interface SessionWriterInterface
Parameters:
id - GUID
Returns:
true if the session was found and terminated

processTumbnail

public void processTumbnail(java.lang.String sessionId,
                            java.lang.String thumbnail)

addThumbnailListener

public void addThumbnailListener(ThumbnailListenerInteface tli)
Description copied from interface: SessionWriterInterface
used for getting thumbnails from client side.

Specified by:
addThumbnailListener in interface SessionWriterInterface
See Also:
ThumbnailListenerInteface

removeThumbnailListener

public void removeThumbnailListener(ThumbnailListenerInteface tli)
Description copied from interface: SessionWriterInterface
remove thumbnail listener

Specified by:
removeThumbnailListener in interface SessionWriterInterface
Parameters:
tli - listener
See Also:
ThumbnailListenerInteface

getSessionIdByNumericId

public java.lang.String getSessionIdByNumericId(int numericId)
Specified by:
getSessionIdByNumericId in interface SessionReaderInterface
Returns:
GUID