refactor: optimize websocket server
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
@ -3,18 +3,19 @@ const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInb
|
||||
const FullHttpRequestMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.FullHttpRequest'))
|
||||
|
||||
export abstract class HttpRequestHandlerAdapter {
|
||||
private _Handler;
|
||||
private _Handler
|
||||
constructor() {
|
||||
let HttpRequestHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
|
||||
isSharable: () => true,
|
||||
acceptInboundMessage: (msg: any) => {
|
||||
return FullHttpRequestMatcher.match(msg)
|
||||
},
|
||||
channelRead0: this.channelRead0.bind(this)
|
||||
})
|
||||
this._Handler = new HttpRequestHandlerAdapterImpl();
|
||||
this._Handler = new HttpRequestHandlerAdapterImpl()
|
||||
}
|
||||
abstract channelRead0(ctx: any, request: any);
|
||||
abstract channelRead0(ctx: any, request: any)
|
||||
getHandler() {
|
||||
return this._Handler;
|
||||
return this._Handler
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ export abstract class TextWebSocketFrameHandlerAdapter {
|
||||
private _Handler
|
||||
constructor() {
|
||||
let TextWebSocketFrameHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
|
||||
isSharable: () => true,
|
||||
userEventTriggered: this.userEventTriggered.bind(this),
|
||||
acceptInboundMessage: (msg: any) => {
|
||||
return TextWebSocketFrameMatcher.match(msg)
|
||||
|
@ -4,6 +4,7 @@ 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),
|
||||
|
Reference in New Issue
Block a user