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

21 lines
606 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 => {
connection.on('text', function (result) {
console.log('发送消息', result)
})
connection.on('connect', function (code) {
console.log('开启连接', code)
})
connection.on('close', function (code) {
console.log('关闭连接', code)
})
connection.on('error', function (code) {
console.log('异常关闭', code)
})
})
return server
}
module.exports = createServer()