API Docs for: 0.2.2
Show:

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

Methods

_bindHandlers

()

Setting up the specifics listeners for the socket

_emit

(
  • name
  • params
)

Simply emit a specific action on the socket

Parameters:

  • name String

    The name of the action to send

  • params Object

    The 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 String

    Contains the unique string GUID

_handleHttpGet

(
  • req
  • res
  • next
)
String

Return the saved data from store

Requested from R.Store server-side or client-side

Parameters:

  • req Object

    The classical request

  • res Object

    The response to send

  • next Object

Returns:

String:

val The computed json value

_handleHttpPost

(
  • req
  • res
)
String

Parameters:

  • req Object

    The classical request

  • res Object

    The response to send

Returns:

String:

str

_handleListenTo

(
  • params
)

Maps the triggered event with the listenTo methods

Parameters:

  • params Object

    Contains the eventName provided by client

_handleSessionExpire

(
  • guid
)

Parameters:

  • guid String

    Unique 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 Object

    The socket used in the connection

_handleSocketDisconnection

(
  • uniqueId
)

Destroy a R.SimpleUplinkServer.Connection.
Triggered when a socket connection is closed

Parameters:

  • uniqueId String

    The unique Id of the connection

_handleSubscribeTo

(
  • params
)

Maps the triggered event with the _subscribeTo methods

Parameters:

  • params Object

    Contains the key provided by client

_handleUnlistenFrom

(
  • params
)

Maps the triggered event with the unlistenFrom methods

Parameters:

  • params Object

    Contains the eventName provided by client

_handleUnsubscribeFrom

(
  • params
)

Maps the triggered event with the _unsubscribeFrom methods

Parameters:

  • params Object

    Contains the key provided by client

_linkSession

(
  • connection
  • guid
)
Object

Link a Session in order to set up subscribing and unsubscribing methods uplink-server-side

Parameters:

  • connection SimpleUplinkServer.Connection

    The created connection

  • guid String

    Unique string GUID

Returns:

Object:

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
)
Function

Unlink a Session

Parameters:

  • connection SimpleUplinkServer.Connection
  • guid String

    Unique string GUID

Returns:

Function:

fn

attachConnection

(
  • connection
)
Object

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.Connection

    the current created connection

Returns:

Object:

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
)
SimpleUplinkServerInstance

Initializes the SimpleUplinkServer according to the specifications provided

Parameters:

  • specs Object

    All the specifications of the SimpleUplinkServer

Returns:

SimpleUplinkServerInstance:

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 String

    The name of the action to send

  • params Object

    The 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
)
Function

Provides data from store.
Called when the fetching data occurs.
Requested by GET from R.Store server-side or client-side

Parameters:

  • key String

    The specified key to set

Returns:

Function:

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 Object

    The specified App

  • prefix String

    The prefix string that will be requested. Tipically "/uplink"

listenTo

(
  • eventName
)

Create a listener for the events

Parameters:

  • eventName String

    The 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
)
Function

Saves data in store. Called by another server that will provide data for each updated data

Parameters:

  • key String

    The specified key to set

  • val String

    The value to save

Returns:

Function:

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 String

    The key to subscribe

subscribeTo

(
  • key
)

Method invoked by client via socket emit
Remove a listener according to the key

Parameters:

  • key String

    The key to unsubscribe

terminate

()

unlistenFrom

(
  • eventName
)

Remove a listener from the events

Parameters:

  • eventName String

    The name of the event that will be unregistered