This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-cli/scripts/server.js
2019-11-12 10:44:43 +08:00

29 lines
867 B
JavaScript

const ws = require('nodejs-websocket')
const createServer = () => {
let server = ws.createServer(connection => {
console.log('connected', connection.key)
connection.on('text', function (result) {
console.log('text', result)
let resultObject = JSON.parse(result)
switch(resultObject.cmd) {
case 'debug':
let contextId = resultObject.contextId
break
}
})
connection.on('connect', function (code) {
console.log('connect', code)
})
connection.on('close', function (code) {
console.log('close', code)
})
connection.on('error', function (code) {
console.log('error', code)
})
})
return server
}
module.exports = createServer()