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

22 lines
628 B
JavaScript
Raw Normal View History

2019-08-03 10:19:56 +08:00
const ws = require('nodejs-websocket')
const createServer = () => {
let server = ws.createServer(connection => {
2019-08-13 17:39:07 +08:00
console.log('connected', connection.key)
2019-08-03 10:19:56 +08:00
connection.on('text', function (result) {
2019-08-13 17:39:07 +08:00
console.log('text', result)
2019-08-03 10:19:56 +08:00
})
connection.on('connect', function (code) {
2019-08-13 17:39:07 +08:00
console.log('connect', code)
2019-08-03 10:19:56 +08:00
})
connection.on('close', function (code) {
2019-08-13 17:39:07 +08:00
console.log('close', code)
2019-08-03 10:19:56 +08:00
})
connection.on('error', function (code) {
2019-08-13 17:39:07 +08:00
console.log('error', code)
2019-08-03 10:19:56 +08:00
})
})
return server
}
module.exports = createServer()