This commit is contained in:
MiTiX
2020-03-02 14:53:23 +07:00
parent f2c263eefa
commit 2ae7118139
4280 changed files with 484929 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
'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)
}