0.3.8 Update Deps, Clean up package.json. Redo server example
parent
16beda57ae
commit
a8cbea5c66
|
@ -1,17 +1,20 @@
|
||||||
import Socket from '../src'
|
import Socket from '../src'
|
||||||
|
|
||||||
async function packetProcess(packet) {
|
async function packetProcess(packet) {
|
||||||
|
// Here one registers a packet processor which gets an plain object hash from the client
|
||||||
|
// should return a promise
|
||||||
|
// for example if client sends a property cmd on can take action on that
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
let res = {}
|
let res = {}
|
||||||
console.log('processing')
|
switch (packet.cmd) {
|
||||||
if (packet.cmd !== 'doit') {
|
case 'echo':
|
||||||
res.response = `command ${packet.cmd} was unknown at server echo payload back`
|
res.msg = 'Echoing Back any payload propery'
|
||||||
res.payload = packet.payload
|
res.payload = packet.payload
|
||||||
console.log(JSON.stringify(res))
|
this.push(res)
|
||||||
} else {
|
break
|
||||||
res.cmd = 'doit'
|
default:
|
||||||
res.response = 'take some action in browser like color a button green'
|
res.msg = `.cmd, command ${packet.cmd} was unknown at server`
|
||||||
res.payload = {button:'on'}
|
res.sent_packet = packet
|
||||||
}
|
}
|
||||||
resolve(res)
|
resolve(res)
|
||||||
})
|
})
|
||||||
|
|
21
package.json
21
package.json
|
@ -1,14 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "@uci/websocket",
|
"name": "@uci/websocket",
|
||||||
"version": "0.3.7",
|
"version": "0.3.8",
|
||||||
"description": "JSON packet host websocket server",
|
"description": "JSON packet host websocket server",
|
||||||
"main": "src",
|
"main": "src",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"testw": "mocha -r esm test/*.test.mjs --watch --recurse",
|
"example": "node -r esm examples/server",
|
||||||
"test": "mocha -r esm --timeout 10000 test/*.test.mjs",
|
"dev": "UCI_ENV=dev UCI_LOG_LEVEL=debug ./node_modules/.bin/nodemon -r esm examples/server"
|
||||||
"testlog": "DEBUG=true mocha -r esm --timeout 10000 test/*.test.mjs",
|
|
||||||
"testci": "istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec --recursive && codecov || true",
|
|
||||||
"s": "DEBUG=true node -r esm examples/server"
|
|
||||||
},
|
},
|
||||||
"author": "David Kebler",
|
"author": "David Kebler",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -34,18 +31,16 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
"codecov": "^3.1.0",
|
"esm": "^3.2.25",
|
||||||
"esm": "^3.0.84",
|
"mocha": "^6.2.0",
|
||||||
"istanbul": "^0.4.5",
|
"nodemon": "^1.19.1"
|
||||||
"mocha": "^5.0.1",
|
|
||||||
"nodemon": "^1.18.6"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@uci-utils/logger": "0.0.14",
|
"@uci-utils/logger": "0.0.15",
|
||||||
"await-to-js": "^2.1.1",
|
"await-to-js": "^2.1.1",
|
||||||
"better-try-catch": "^0.6.2",
|
"better-try-catch": "^0.6.2",
|
||||||
"clone": "^2.1.2",
|
"clone": "^2.1.2",
|
||||||
"death": "^1.1.0",
|
"death": "^1.1.0",
|
||||||
"ws": "^6.2.0"
|
"ws": "^7.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue