refactor(websocket): upgrade socket.io

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-11-18 16:21:56 +08:00
parent 17af1fd49b
commit 47478e13aa
26 changed files with 1844 additions and 1680 deletions

View File

@@ -0,0 +1,20 @@
const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatcher')
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
const FullHttpRequestMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.FullHttpRequest'))
export abstract class HttpRequestHandlerAdapter {
private _Handler;
constructor() {
let HttpRequestHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
acceptInboundMessage: (msg: any) => {
return FullHttpRequestMatcher.match(msg)
},
channelRead0: this.channelRead0.bind(this)
})
this._Handler = new HttpRequestHandlerAdapterImpl();
}
abstract channelRead0(ctx: any, request: any);
getHandler() {
return this._Handler;
}
}

View File

@@ -0,0 +1,3 @@
export * from './text_websocket_frame'
export * from './websocket'
export * from './httprequest'

View File

@@ -0,0 +1,24 @@
const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatcher')
const TextWebSocketFrameMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.websocketx.TextWebSocketFrame'))
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
export abstract class TextWebSocketFrameHandlerAdapter {
private _Handler
constructor() {
let TextWebSocketFrameHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
userEventTriggered: this.userEventTriggered.bind(this),
acceptInboundMessage: (msg: any) => {
return TextWebSocketFrameMatcher.match(msg)
},
channelRead0: this.channelRead0.bind(this),
exceptionCaught: this.exceptionCaught.bind(this)
})
this._Handler = new TextWebSocketFrameHandlerAdapterImpl()
}
abstract userEventTriggered(ctx: any, evt: any)
abstract channelRead0(ctx: any, msg: any)
abstract exceptionCaught(ctx: any, cause: Error)
getHandler() {
return this._Handler
}
}

View File

@@ -0,0 +1,21 @@
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
export abstract class WebSocketHandlerAdapter {
private _Handler
constructor() {
let ChannelInboundHandlerAdapterImpl = Java.extend(ChannelInboundHandlerAdapter, {
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)
abstract channelInactive(ctx: any)
abstract channelUnregistered(ctx: any)
abstract exceptionCaught(ctx: any, cause: Error)
getHandler() {
return this._Handler
}
}