AbstractSocketService

AbstractSocketService ⇐ Abstract

Kind: global abstract class
Extends: Abstract
Singleton:
Properties

NameTypeDescription
serverUrlstring

The full url (including protocol and port) to the socket server

connectedboolean

(default=false) True if the connection is established and ready to be used

nbConnectErrornumber

The number of time we tried to connect to have the connection established

AbstractSocketService()

Enables real-time bidirectional communication, via web-sockets or similar.

connect(options) ⇒ Promise.<boolean, Error>

Initialize the connection

Kind: instance method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

ParamTypeDescription
optionsObject

socket's options

options.onCallbackfunction

The function called when the message is received (will be set as soon as socket is created)

disconnect() ⇒ Promise.<boolean, Error>

Close the connection

Kind: instance method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

emit(data) ⇒ Promise.<boolean, Error>

Emit a message to the server

Kind: instance method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

ParamType
dataObject

on(callback)

Listen messages

Kind: instance method of AbstractSocketService

ParamTypeDescription
callbackfunction

The function called when the message is received

onDisconnect()

Called when the connection is disconnectd

Kind: instance method of AbstractSocketService

onConnect()

Called when the connection is up and ready to be used

Kind: instance method of AbstractSocketService

onError()

Called when an error occur

Kind: instance method of AbstractSocketService

_connect(options) ⇒ Promise.<boolean, Error>

Implementation of the connect method

Kind: instance abstract method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

ParamTypeDescription
optionsObject

options socket

_disconnect() ⇒ Promise.<boolean, Error>

Implementation of the disconnect method

Kind: instance abstract method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

_emit(data) ⇒ Promise.<boolean, Error>

Implementation of the emit method

Kind: instance abstract method of AbstractSocketService
Returns: Promise.<boolean, Error> - A Promise resolved in case of success rejected otherwise with the reason of the failure

ParamType
dataObject

_on(callback)

Implementation of the on method

Kind: instance method of AbstractSocketService

ParamTypeDescription
callbackfunction

The function called when the message is received