EthermerisManager

The Ethermeris Manager. This class holds multiple servers and automatically routes clients to specific servers. Handles WebSocket upgrades, WebRTC Signalling, and ICE Candidate exchanges. Also hosts the client library file.

new EthermerisManager(settings: ManagerSettings)
Parameters
settings (ManagerSettings) Ethermeris Manager Settings
Instance Members
createServer(settings)
attach(server)

EthermerisServer

The Ethermeris Server. This class contains the state, networker and event emitter. It is not meant to be used bare. Use the Manager to create servers instead.

new EthermerisServer(settings: ServerSettings)
Parameters
settings (ServerSettings) Ethermeris Server Settings
Instance Members
getState()
getWebSocketServer()
getClients()
addCompressor(settings)
emitToAll(name, data)
on(eventName, listener)
off(eventName, listener)
once(eventName, listener)
respond(eventName, listener)
setState(newPartialState, clientModifier?, shallowMerge?)

EthermerisServer~clientModifierCallback

Pre-flight per client state difference modifier callback. Its return value will be the new diff to send to the client.

EthermerisServer~clientModifierCallback(client: ClientConnection, differences: Object)

Type: Function

Parameters
client (ClientConnection) The specific client.
differences (Object) The object differences to be modified.

EthermerisClient

The Ethermeris Client. This class contains WebSocket/WebRTC connections, an event emitter, the local state, and responders. This class is only meant to be used on the browser to connect with Ethermeris servers.

new EthermerisClient(settings: ClientSettings)
Parameters
settings (ClientSettings) Ethermeris Client Settings
Instance Members
id
ready
socket
init()
destroy()
on(eventName, listener)
off(eventName, listener)
once(eventName, listener)
respond(eventName, callback, listener)
emit(name, data)
request(eventName, data)

EthermerisClient#disconnection

Disconnection Event.

EthermerisClient#disconnection
Parameters
disconnectionReason (String) The reason for disconnection.
disconnectionCode (Number) The disconnection code.

EthermerisClient#connection

Connection Event.

EthermerisClient#connection
Parameters
initialState (Object) The entire state object of the server.
initialData (Object) An object containing custom initial data

EthermerisServer#connection

Connection Event.

EthermerisServer#connection
Parameters
client (ClientConnection) The connection of the client that just connected.
clientRequestData (Object) Object containing the data that the client sent over in the connection request.

EthermerisServer#disconnection

Disconnection Event.

EthermerisServer#disconnection
Parameters
client (ClientConnection) The dead connection of the client that just disconnected.

ClientConnection

A Server's Client Connection. This class represents a connection to a client on the server. The server can use this class to send events and requests to the client. Not meant to be used bare.

new ClientConnection()
Instance Members
destroy(reason)
emit(name, data)
request(eventName, data)

ServerSettings

ServerSettings

Type: Object

Properties
serverID ((String | Number)?) : The ID of the server. Used by the client to select a specific server. An ID is automatically generated if omitted.
stateSchema (Object) : The initial state of the server. No new keys should be added to the state after it is set.
getInitialData (Function) : A callback function that returns the initial data that gets sent to the user on connection.
maxMessagesPerSecond (Number) : The maximum amount of messages per second allowed. The client is automatically disconnected if this threshold is broken.
clientTimeout (Number) : The client will disconnect when this amount of time passes with no messages sent from it.
peerSettings (Object) : The RTCPeerConnection settings object.
Related
RTCPeerConnection for further information on RTCPeerConnection's.

ManagerSettings

ManagerSettings

Type: Object

Properties
httpServer (NodeHTTPServer) : The Node.js HTTP Server to attach the manager to.
serverRoute (String?) : The root route that the manager uses for all server communications.

ClientSettings

ClientSettings

Type: Object

Properties
serverID ((String | Number)?) : The ID of the server that the client is attempting to connect to.
verbose (Boolean?) : If set to true, the client's operations are logged to the console.
forceWebSockets (Boolean?) : Forces the client to use WebSockets.
serverRoute (String?) : Root server route to use when signalling and exchanging candidates.
getInitialData (Function?) : This function gets called if initial data is required to connect to the server.
peerSettings (Object) : The RTCPeerConnection settings object.
Related
RTCPeerConnection for further information on RTCPeerConnection's.