Backend
Extends:
Handles connection with the backend.
Responsible for establishing a WebSocket (socket.io) connection with the backend and handling its requests.
It also instantiates Replicator instances for data and log replication. The stateChange events from these are forwarded as: "replicator:data:state" and "replicator:log:state".
Constructor Summary
| Public Constructor | ||
| public |
constructor(name: String, logger: Bunyan, dataDB: PouchDB, logDB: PouchDB) Constructor. |
|
Member Summary
| Public Members | ||
| public |
Replicator instance for dataDB. |
|
| public |
Replicator instance for logDB. |
|
| public |
Station name. |
|
| Private Members | ||
| private |
_log: Bunyan Logger instance. |
|
| private |
_socket: IO Current socket connection with the backend. |
|
| private |
Current socket state. |
|
Method Summary
| Public Methods | ||
| public |
Triggers Replicator#cleanup on the data and log replicators. |
|
| public |
Connects to backend at [url]. |
|
| public |
Disconnects from the backend. |
|
| Protected Methods | ||
| protected |
_updateState(state: String, extraData: Object) Updates the socket state. |
|
Public Constructors
Public Members
Private Members
Public Methods
public async cleanup(): Promise source
Triggers Replicator#cleanup on the data and log replicators.
Emit:
* |
state('cleanup') |
public connect(url: String) source
Connects to backend at [url].
Params:
| Name | Type | Attribute | Description |
| url | String | Backend URL. |
Emit:
* |
state(socketState): socket connection/disconnection. |
public disconnect() source
Disconnects from the backend. Stops the socket. The replicators will keep running until a new connection makes them connect to a different database.
Emit:
* |
state(socketState): socket connection/disconnection. |