revert Merge branch 'main' of http://47.107.152.87:3000/liubiao/APP # Conflicts: # .gitignore # pages/common/index/index.vue # unpackage/dist/dev/app-plus/app-config-service.js # unpackage/dist/dev/app-plus/app-service.js # unpackage/dist/dev/app-plus/app-view.js # unpackage/dist/dev/app-plus/manifest.json # utils/request.js
30 lines
611 B
JavaScript
30 lines
611 B
JavaScript
'use strict'
|
|
|
|
var WebSocketServer = require('ws').Server
|
|
var stream = require('./stream')
|
|
|
|
class Server extends WebSocketServer{
|
|
constructor(opts, cb) {
|
|
super(opts)
|
|
|
|
var proxied = false
|
|
this.on('newListener', function(event) {
|
|
if (!proxied && event === 'stream') {
|
|
proxied = true
|
|
this.on('connection', function(conn, req) {
|
|
this.emit('stream', stream(conn, opts), req)
|
|
})
|
|
}
|
|
})
|
|
|
|
if (cb) {
|
|
this.on('stream', cb)
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports.Server = Server
|
|
module.exports.createServer = function(opts, cb) {
|
|
return new Server(opts, cb)
|
|
}
|