feat: optimize websocket

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-11-13 09:40:47 +08:00
parent d769a9c8ca
commit 7f5929bc87
10 changed files with 195 additions and 126 deletions

View File

@ -3,7 +3,7 @@ const TextWebSocketFrameMatcher = TypeParameterMatcher.get(base.getClass('io.net
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
export abstract class TextWebSocketFrameHandlerAdapter {
private _Handler;
private _Handler
constructor() {
let TextWebSocketFrameHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
userEventTriggered: this.userEventTriggered.bind(this),
@ -13,12 +13,12 @@ export abstract class TextWebSocketFrameHandlerAdapter {
channelRead0: this.channelRead0.bind(this),
exceptionCaught: this.exceptionCaught.bind(this)
})
this._Handler = new TextWebSocketFrameHandlerAdapterImpl();
this._Handler = new TextWebSocketFrameHandlerAdapterImpl()
}
abstract userEventTriggered(ctx: any, evt: any);
abstract channelRead0(ctx: any, msg: any);
abstract exceptionCaught(ctx: any, cause: Error);
abstract userEventTriggered(ctx: any, evt: any)
abstract channelRead0(ctx: any, msg: any)
abstract exceptionCaught(ctx: any, cause: Error)
getHandler() {
return this._Handler;
return this._Handler
}
}

View File

@ -1,17 +1,19 @@
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
export abstract class WebSocketHandlerAdapter {
private _Handler;
private _Handler
constructor() {
let ChannelInboundHandlerAdapterImpl = Java.extend(ChannelInboundHandlerAdapter, {
channelRead: this.channelRead.bind(this),
channelUnregistered: this.exceptionCaught.bind(this),
exceptionCaught: this.exceptionCaught.bind(this)
})
this._Handler = new ChannelInboundHandlerAdapterImpl()
}
abstract channelRead(ctx: any, channel: any);
abstract exceptionCaught(ctx: any, cause: Error);
abstract channelRead(ctx: any, channel: any)
abstract channelUnregistered(ctx: any)
abstract exceptionCaught(ctx: any, cause: Error)
getHandler() {
return this._Handler;
return this._Handler
}
}