AbstractSocketService
On this page
- AbstractSocketService ⇐
Abstract- AbstractSocketService()
- connect(options) ⇒
Promise.<boolean, Error> - disconnect() ⇒
Promise.<boolean, Error> - emit(data) ⇒
Promise.<boolean, Error> - on(callback)
- onDisconnect()
- onConnect()
- onError()
- _connect(options) ⇒
Promise.<boolean, Error> - _disconnect() ⇒
Promise.<boolean, Error> - _emit(data) ⇒
Promise.<boolean, Error> - _on(callback)
AbstractSocketService ⇐ Abstract
Kind: global abstract class
Extends: Abstract
Singleton:
Properties
| Name | Type | Description |
|---|---|---|
| serverUrl | string | The full url (including protocol and port) to the socket server |
| connected | boolean | (default=false) True if the connection is established and ready to be used |
| nbConnectError | number | The number of time we tried to connect to have the connection established |
- AbstractSocketService ⇐
Abstract- new AbstractSocketService()
- .connect(options) ⇒
Promise.<boolean, Error> - .disconnect() ⇒
Promise.<boolean, Error> - .emit(data) ⇒
Promise.<boolean, Error> - .on(callback)
- .onDisconnect()
- .onConnect()
- .onError()
- ._connect(options) ⇒
Promise.<boolean, Error> - ._disconnect() ⇒
Promise.<boolean, Error> - ._emit(data) ⇒
Promise.<boolean, Error> - ._on(callback)
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
| Param | Type | Description |
|---|---|---|
| options | Object | socket's options |
| options.onCallback | function | 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
| Param | Type |
|---|---|
| data | Object |
on(callback)
Listen messages
Kind: instance method of AbstractSocketService
| Param | Type | Description |
|---|---|---|
| callback | function | 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
| Param | Type | Description |
|---|---|---|
| options | Object | 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
| Param | Type |
|---|---|
| data | Object |
_on(callback)
Implementation of the on method
Kind: instance method of AbstractSocketService
| Param | Type | Description |
|---|---|---|
| callback | function | The function called when the message is received |