R.SimpleUplinkServer Class
SimpleUplinkServer represents an uplink-server that will be able to store data via an other server.
There also will be able to notify each client who suscribes to a data when an update will occurs thanks to socket
SimpleUplinkServer will be requested by GET or POST via R.Uplink server-side and client-side
Item Index
Methods
- _bindHandlers
- _emit
- _expire
- _handleDisconnect
- _handleHandshake
- _handleHandshake
- _handleHttpGet
- _handleHttpPost
- _handleListenTo
- _handleSessionExpire
- _handleSocketConnection
- _handleSocketDisconnection
- _handleSubscribeTo
- _handleUnlistenFrom
- _handleUnsubscribeFrom
- _linkSession
- _signalEvent
- _signalUpdate
- _unlinkSession
- attachConnection
- Connection
- createApp
- detachConnection
- emit
- emitDebug
- emitError
- emitEvent
- emitLog
- emitWarn
- getStore
- installHandlers
- listenTo
- Session
- setStore
- SimpleUplinkServerInstance
- subscribeTo
- subscribeTo
- terminate
- unlistenFrom
Methods
_bindHandlers
()
Setting up the specifics listeners for the socket
_emit
-
name
-
params
Simply emit a specific action on the socket
Parameters:
-
name
StringThe name of the action to send
-
params
ObjectThe params
_expire
()
_handleDisconnect
()
Triggered by the recently disconnected client.
_handleHandshake
()
Triggered by the recently disconnected client.
Removes methods of subscriptions
_handleHandshake
-
params
Triggered by the recently connected client.
Combines methods of subscriptions that will be triggered by the client via socket listening
Parameters:
-
params
StringContains the unique string GUID
_handleHttpGet
-
req
-
res
-
next
Return the saved data from store
Requested from R.Store server-side or client-side
Parameters:
-
req
ObjectThe classical request
-
res
ObjectThe response to send
-
next
Object
Returns:
val The computed json value
_handleHttpPost
-
req
-
res
Parameters:
-
req
ObjectThe classical request
-
res
ObjectThe response to send
Returns:
str
_handleListenTo
-
params
Maps the triggered event with the listenTo methods
Parameters:
-
params
ObjectContains the eventName provided by client
_handleSessionExpire
-
guid
Parameters:
-
guid
StringUnique string GUID
_handleSocketConnection
-
socket
Create a R.SimpleUplinkServer.Connection in order to set up handler items.
Triggered when a socket connection is established
Parameters:
-
socket
ObjectThe socket used in the connection
_handleSocketDisconnection
-
uniqueId
Destroy a R.SimpleUplinkServer.Connection.
Triggered when a socket connection is closed
Parameters:
-
uniqueId
StringThe unique Id of the connection
_handleSubscribeTo
-
params
Maps the triggered event with the _subscribeTo methods
Parameters:
-
params
ObjectContains the key provided by client
_handleUnlistenFrom
-
params
Maps the triggered event with the unlistenFrom methods
Parameters:
-
params
ObjectContains the eventName provided by client
_handleUnsubscribeFrom
-
params
Maps the triggered event with the _unsubscribeFrom methods
Parameters:
-
params
ObjectContains the key provided by client
_linkSession
-
connection
-
guid
Link a Session in order to set up subscribing and unsubscribing methods uplink-server-side
Parameters:
-
connection
SimpleUplinkServer.ConnectionThe created connection
-
guid
StringUnique string GUID
Returns:
the object that contains methods subscriptions/unsubscriptions
_signalEvent
()
The client is listening on the action "event" socket
_signalUpdate
()
The client is listening on the action "update" socket
_unlinkSession
-
connection
-
guid
Unlink a Session
Parameters:
-
connection
SimpleUplinkServer.Connection -
guid
StringUnique string GUID
Returns:
fn
attachConnection
-
connection
Bind the subscribing and unsubscribing methods when a connection is established
Methods that trigger on client issues (like emit("subscribeTo"), emit("unsubscribeFrom"))
Parameters:
-
connection
SimpleUplinkServer.Connectionthe current created connection
Returns:
the binded object with methods
Connection
-
pid
-
socket
-
handleSocketDisconnection
-
linkSession
-
unlinkSession
Setting up a connection in order to initialies methods and to provides specifics listeners on the socket
Parameters:
-
pid
Object -
socket
Object -
handleSocketDisconnection
Object -
linkSession
Object -
unlinkSession
Object
createApp
-
specs
Initializes the SimpleUplinkServer according to the specifications provided
Parameters:
-
specs
ObjectAll the specifications of the SimpleUplinkServer
Returns:
SimpleUplinkServerInstance The instance of the created SimpleUplinkServer
detachConnection
()
Remove the previously added connection, and clean the message queue
emit
-
name
-
params
Simply emit a specific action on the socket
Parameters:
-
name
StringThe name of the action to send
-
params
ObjectThe params
emitDebug
-
guid
-
params
Parameters:
-
guid
String -
params
Object
emitError
-
guid
-
params
Parameters:
-
guid
String -
params
Object
emitEvent
-
eventName
-
params
Parameters:
-
eventName
String -
params
Object
emitLog
-
guid
-
params
Parameters:
-
guid
String -
params
Object
emitWarn
-
guid
-
params
Parameters:
-
guid
String -
params
Object
getStore
-
key
Provides data from store.
Called when the fetching data occurs.
Requested by GET from R.Store server-side or client-side
Parameters:
-
key
StringThe specified key to set
Returns:
installHandlers
-
app
-
prefix
Setting up UplinkServer.
- create the socket connection
- init get and post app in order to provide data via R.Uplink.fetch
Parameters:
-
app
ObjectThe specified App
-
prefix
StringThe prefix string that will be requested. Tipically "/uplink"
listenTo
-
eventName
Create a listener for the events
Parameters:
-
eventName
StringThe name of the event that will be registered
Session
-
pid
-
storeEvents
-
eventsEvents
-
sessionsEvents
-
timeout
Setting up a session
Parameters:
-
pid
Object -
storeEvents
Object -
eventsEvents
Object -
sessionsEvents
Object -
timeout
Object
setStore
-
key
-
val
Saves data in store. Called by another server that will provide data for each updated data
Parameters:
-
key
StringThe specified key to set
-
val
StringThe value to save
Returns:
SimpleUplinkServerInstance
()
Setting up necessary methods for the SimpleUplinkServer
subscribeTo
-
key
Method invoked by client via socket emit
Store the _signalUpdate method in subscription
Add a listener that will call _signalUpdate when triggered
Parameters:
-
key
StringThe key to subscribe
subscribeTo
-
key
Method invoked by client via socket emit
Remove a listener according to the key
Parameters:
-
key
StringThe key to unsubscribe
terminate
()
unlistenFrom
-
eventName
Remove a listener from the events
Parameters:
-
eventName
StringThe name of the event that will be unregistered