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

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

View File

@@ -0,0 +1,26 @@
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
export abstract class WebSocketHandlerAdapter {
private _Handler
constructor() {
let ChannelInboundHandlerAdapterImpl = Java.extend(ChannelInboundHandlerAdapter, {
isSharable: () => true,
channelRead: this.channelRead.bind(this),
channelInactive: this.channelInactive.bind(this),
channelUnregistered: this.exceptionCaught.bind(this),
exceptionCaught: this.exceptionCaught.bind(this)
})
this._Handler = new ChannelInboundHandlerAdapterImpl()
}
abstract channelRead(ctx: any, channel: any)
channelInactive(ctx: any) {
ctx.fireChannelInactive()
}
channelUnregistered(ctx: any) {
ctx.fireChannelUnregistered()
}
abstract exceptionCaught(ctx: any, cause: Error)
getHandler() {
return this._Handler
}
}