C# Class Simpl.OODSS.Distributed.Server.WebSocketOODSSServer

Inheritance: Simpl.OODSS.Distributed.Impl.AbstractServer, ServerProcessor
Show file Open project: ecologylab/simplCSharp Class Usage Examples

Protected Properties

Property Type Description
ClientSessionManagerMap WebSocketClientSessionManager>.DictionaryList
CloseEvent System.Threading.AutoResetEvent
DataReceiveEvent System.Threading.AutoResetEvent
MaxMessageSize int
MessageReceiveEvent System.Threading.AutoResetEvent
OpenedEvent System.Threading.AutoResetEvent
ServerThread Thread

Public Methods

Method Description
ProcessRead ( WebSocketSession session, long uid, string message ) : void

process the recieved message and uid. if sessionManager does not exist, create add it to the client session manager map process the message and send the response message back to the client

RestoreContextManagerFromSessionId ( string incomingSessionId, string newSessionId, BaseSessionManager newSessionManager ) : bool

restore old sessionManager for recovered session. returns true if the session is restored, false if the old session doesn't exist thus cannot be restored.

Start ( ) : bool

start server

Stop ( ) : void

stop server

WebSocketOODSSServer ( SimplTypesScope serverTranslationScope, Scope applicationObjectScope, int idleConnectionTimeout = -1, int maxMessageSize = -1, int port ) : System

Initialize a websocket oodss server object

processSessionClosed ( string sessionid ) : void

Protected Methods

Method Description
GenerateContextManager ( string sessionId, SimplTypesScope translationScope, Scope applicationObjectScope ) : BaseSessionManager

Generate WebSocketClientSessionManager

SendUpdateMessage ( string sessionId, UpdateMessage updateMessage ) : void

called by the session manager to send out update message.

WebSocketServer_SessionClosed ( WebSocketSession session, CloseReason reason ) : void

Private Methods

Method Description
CreatePacketFromMessageAndSend ( long uid, ServiceMessage message, WebSocketSession session ) : void

helper function to generate and send byte array message to client session.

SetUpWebSocketServer ( int port ) : void
WebSocketServer_NewDataReceived ( WebSocketSession session, byte e ) : void
WebSocketServer_NewMessageReceived ( WebSocketSession session, string e ) : void
WebSocketServer_NewSessionConnected ( WebSocketSession session ) : void

Method Details

GenerateContextManager() protected method

Generate WebSocketClientSessionManager
protected GenerateContextManager ( string sessionId, SimplTypesScope translationScope, Scope applicationObjectScope ) : BaseSessionManager
sessionId string client's session id
translationScope Simpl.Serialization.SimplTypesScope translation scope for the server
applicationObjectScope Scope server's application scope
return Simpl.OODSS.Distributed.Server.ClientSessionManager.BaseSessionManager

ProcessRead() public method

process the recieved message and uid. if sessionManager does not exist, create add it to the client session manager map process the message and send the response message back to the client
public ProcessRead ( WebSocketSession session, long uid, string message ) : void
session WebSocketSession the client's websocket session
uid long uid of the message
message string message in serialized form
return void

RestoreContextManagerFromSessionId() public method

restore old sessionManager for recovered session. returns true if the session is restored, false if the old session doesn't exist thus cannot be restored.
public RestoreContextManagerFromSessionId ( string incomingSessionId, string newSessionId, BaseSessionManager newSessionManager ) : bool
incomingSessionId string received sesion id information
newSessionId string
newSessionManager Simpl.OODSS.Distributed.Server.ClientSessionManager.BaseSessionManager a new session manager
return bool

SendUpdateMessage() protected method

called by the session manager to send out update message.
protected SendUpdateMessage ( string sessionId, UpdateMessage updateMessage ) : void
sessionId string client's session id
updateMessage Simpl.OODSS.Messages.UpdateMessage update message
return void

Start() public method

start server
public Start ( ) : bool
return bool

Stop() public method

stop server
public Stop ( ) : void
return void

WebSocketOODSSServer() public method

Initialize a websocket oodss server object
public WebSocketOODSSServer ( SimplTypesScope serverTranslationScope, Scope applicationObjectScope, int idleConnectionTimeout = -1, int maxMessageSize = -1, int port ) : System
serverTranslationScope Simpl.Serialization.SimplTypesScope translationscope for the oodss messages
applicationObjectScope Scope server object scope
idleConnectionTimeout int
maxMessageSize int
port int
return System

WebSocketServer_SessionClosed() protected method

protected WebSocketServer_SessionClosed ( WebSocketSession session, CloseReason reason ) : void
session WebSocketSession
reason CloseReason
return void

processSessionClosed() public method

public processSessionClosed ( string sessionid ) : void
sessionid string
return void

Property Details

ClientSessionManagerMap protected property

protected DictionaryList ClientSessionManagerMap
return WebSocketClientSessionManager>.DictionaryList

CloseEvent protected property

protected AutoResetEvent,System.Threading CloseEvent
return System.Threading.AutoResetEvent

DataReceiveEvent protected property

protected AutoResetEvent,System.Threading DataReceiveEvent
return System.Threading.AutoResetEvent

MaxMessageSize protected property

protected int MaxMessageSize
return int

MessageReceiveEvent protected property

protected AutoResetEvent,System.Threading MessageReceiveEvent
return System.Threading.AutoResetEvent

OpenedEvent protected property

protected AutoResetEvent,System.Threading OpenedEvent
return System.Threading.AutoResetEvent

ServerThread protected property

protected Thread ServerThread
return Thread