@nkbt/geovis-server
v1.1.0
Published
Server to feed GeoVis with data
Downloads
1
Readme
geovis-server
Server to feed GeoVis with data
Installation
npm install --global @nkbt/geovis-server
Usage
Running server
const {run} = require('@nkbt/geovis-server');
const {
WS_HOST = '0.0.0.0',
WS_PORT = 10000
} = process.env;
run({WS_HOST, WS_PORT});
Supported actions
- PING
request = {
"action": "PING"
}
// Response includes original request message
response = {
"req": {
"action": "PING"
},
"res": {
"time": 1473282575430
}
};
- GEO
request = {
"action": "GEO_START"
}
// no response, but will add client to broadcast list until GEO_STOP is sent
request = {
"action": "GEO_STOP"
}
// no responses anymore
// broadcast GEO to all subscribers
request = {
"action": "GEO_BROADCAST",
"payload": [{
"srcLat": -33.865143,
"srcLon": 151.2099,
"dstLat": -12.462827,
"dstLon": 130.841782,
"value": 7
}]
}
// no response for sender, but will broadcast for all GEO_START subscribers:
broadcast = {
"req": {
"action": "GEO_BROADCAST"
},
"res": [{
"srcLat": -33.865143,
"srcLon": 151.2099,
"dstLat": -12.462827,
"dstLon": 130.841782,
"value": 7
}]
};
Logging
07:09 $ ./bin.js
running server on ws://0.0.0.0:10000
Client connected
<< {"action": "PING"}
>> {"req":{"action":"PING"},"res":{"time":1473282575430}}
<< {"action": "GEO_START"}
<< {"action":"GEO_BROADCAST","payload":[{"srcLat":50.411198,"srcLon":30.446634,"dstLat":55.751244,"dstLon":37.618423,"value":3}]}
>> {"req":{"action":"GEO_BROADCAST"},"res":[{"srcLat":50.411198,"srcLon":30.446634,"dstLat":55.751244,"dstLon":37.618423,"value":3}]}
<< {"action":"GEO_BROADCAST","payload":[{srcLat":55.751244,"srcLon":37.618423,"dstLat":49.246292,"dstLon":-123.116226,"value":2}]}
>> {"req":{"action":"GEO_BROADCAST"},"res":[{"srcLat":55.751244,"srcLon":37.618423,"dstLat":49.246292,"dstLon":-123.116226,"value":2}]}
<< {"action": "GEO_STOP"}
^C
Development and testing
Currently is being developed and tested with the latest stable Node 6
under OSX
.
git clone [email protected]:nkbt/geovis-server.git
cd geovis-server
npm install
Tests
# to run tests
npm test
# to generate test coverage (./coverage)
npm run cov
License
MIT