0.3.8 Update Deps, Clean up package.json. Redo server example
This commit is contained in:
parent
16beda57ae
commit
a8cbea5c66
2 changed files with 19 additions and 21 deletions
|
@ -1,17 +1,20 @@
|
|||
import Socket from '../src'
|
||||
|
||||
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 => {
|
||||
let res = {}
|
||||
console.log('processing')
|
||||
if (packet.cmd !== 'doit') {
|
||||
res.response = `command ${packet.cmd} was unknown at server echo payload back`
|
||||
switch (packet.cmd) {
|
||||
case 'echo':
|
||||
res.msg = 'Echoing Back any payload propery'
|
||||
res.payload = packet.payload
|
||||
console.log(JSON.stringify(res))
|
||||
} else {
|
||||
res.cmd = 'doit'
|
||||
res.response = 'take some action in browser like color a button green'
|
||||
res.payload = {button:'on'}
|
||||
this.push(res)
|
||||
break
|
||||
default:
|
||||
res.msg = `.cmd, command ${packet.cmd} was unknown at server`
|
||||
res.sent_packet = packet
|
||||
}
|
||||
resolve(res)
|
||||
})
|
||||
|
|
21
package.json
21
package.json
|
@ -1,14 +1,11 @@
|
|||
{
|
||||
"name": "@uci/websocket",
|
||||
"version": "0.3.7",
|
||||
"version": "0.3.8",
|
||||
"description": "JSON packet host websocket server",
|
||||
"main": "src",
|
||||
"scripts": {
|
||||
"testw": "mocha -r esm test/*.test.mjs --watch --recurse",
|
||||
"test": "mocha -r esm --timeout 10000 test/*.test.mjs",
|
||||
"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"
|
||||
"example": "node -r esm examples/server",
|
||||
"dev": "UCI_ENV=dev UCI_LOG_LEVEL=debug ./node_modules/.bin/nodemon -r esm examples/server"
|
||||
},
|
||||
"author": "David Kebler",
|
||||
"license": "MIT",
|
||||
|
@ -34,18 +31,16 @@
|
|||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"codecov": "^3.1.0",
|
||||
"esm": "^3.0.84",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^5.0.1",
|
||||
"nodemon": "^1.18.6"
|
||||
"esm": "^3.2.25",
|
||||
"mocha": "^6.2.0",
|
||||
"nodemon": "^1.19.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@uci-utils/logger": "0.0.14",
|
||||
"@uci-utils/logger": "0.0.15",
|
||||
"await-to-js": "^2.1.1",
|
||||
"better-try-catch": "^0.6.2",
|
||||
"clone": "^2.1.2",
|
||||
"death": "^1.1.0",
|
||||
"ws": "^6.2.0"
|
||||
"ws": "^7.1.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue