new ServerEventService(server, route, wait_intervalopt)
- Description:
Implements a mechanism to react to events from the server.
-
A POST service is attached to the given route.
-
This is the server side of a simple client/server mechanism for persistent data.
-
The local service is attached to an express web mechanism, using a construct of the form:
// Loads required packages const express = require("express"); const server = express(); const ServerEventService = require("./ServerEventService.js"); // Defines a minimal persistantdata service new ServerEventService(server, "/_serverevent"); server.listen(8080);
-
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
server |
express | The express server mechanism. |
||
route |
string |
/_serverevent
|
The route, both :
|
|
wait_interval |
uint |
<optional> |
10
|
The waiting interval between scanning the event queue, minimal value is 10. |
Methods
(inner) doQuery()
- Description:
Implements the event server management query. The even server management queries are:
action=clear
:- Purges all pending events.
add(value)
- Description:
Appends an event to the event queue.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The event value, it might be a JSON string. |
clear()
- Description:
Clears the event queue.
addClock(period, count)
- Description:
Generates a periodic event (mainly for debugging purpose).
- The event value writes
$index
, the occurence index, starting from 0.
- The event value writes
Parameters:
Name | Type | Description |
---|---|---|
period |
uint | The clock period in millisecond, 0 to stop the clock. |
count |
uint | The maximal number of event, 0 if no bound. |