feat: 完善client相关功能 重构server部分

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2021-08-14 12:43:20 +08:00
parent 774763be13
commit 53502e12cf
34 changed files with 2893 additions and 20 deletions

View File

@@ -49,9 +49,6 @@ export abstract class WebSocketServer extends EventEmitter {
this.execute(handler, (websocket) => websocket.emit(ServerEvent.disconnect, cause))
}
protected onerror(handler: any, error: Error) {
if (global.debug) {
console.ex(error)
}
this.execute(handler, (websocket) => websocket.emit(ServerEvent.error, error))
}
protected execute(handler: any, callback: (websocket: WebSocketClient) => void) {
@@ -82,9 +79,9 @@ export const attach = (instance, options) => {
}, options)
let WebSocketServerImpl = undefined
if (instance.class.name.startsWith('io.netty.channel')) {
WebSocketServerImpl = require("../netty").NettyWebSocketServer
WebSocketServerImpl = require("./netty").NettyWebSocketServer
} else {
WebSocketServerImpl = require("../tomcat").TomcatWebSocketServer
WebSocketServerImpl = require("./tomcat").TomcatWebSocketServer
}
return new WebSocketServerImpl(instance, options)
}