feat: complate socket.io base framework
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
@ -2,18 +2,19 @@ const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatc
|
||||
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
|
||||
const FullHttpRequestMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.FullHttpRequest'))
|
||||
|
||||
export default abstract class HttpRequestHandlerAdapter {
|
||||
export abstract class HttpRequestHandlerAdapter {
|
||||
private _Handler;
|
||||
constructor() {
|
||||
this._Handler == Java.extend(SimpleChannelInboundHandler, {
|
||||
let HttpRequestHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
|
||||
acceptInboundMessage: (msg: any) => {
|
||||
return FullHttpRequestMatcher.match(msg)
|
||||
},
|
||||
channelRead0: this.channelRead0
|
||||
channelRead0: this.channelRead0.bind(this)
|
||||
})
|
||||
this._Handler = new HttpRequestHandlerAdapterImpl();
|
||||
}
|
||||
abstract channelRead0(ctx: any, msg: any);
|
||||
abstract channelRead0(ctx: any, request: any);
|
||||
getHandler() {
|
||||
return this._Handler;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
packages/websocket/src/netty/index.ts
Normal file
3
packages/websocket/src/netty/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './text_websocket_frame'
|
||||
export * from './websocket'
|
||||
export * from './httprequest'
|
@ -2,16 +2,17 @@ const TypeParameterMatcher = Java.type('io.netty.util.internal.TypeParameterMatc
|
||||
const TextWebSocketFrameMatcher = TypeParameterMatcher.get(base.getClass('io.netty.handler.codec.http.websocketx.TextWebSocketFrame'))
|
||||
const SimpleChannelInboundHandler = Java.type('io.netty.channel.SimpleChannelInboundHandler')
|
||||
|
||||
export default abstract class TextWebSocketFrameHandlerAdapter {
|
||||
export abstract class TextWebSocketFrameHandlerAdapter {
|
||||
private _Handler;
|
||||
constructor() {
|
||||
this._Handler == Java.extend(SimpleChannelInboundHandler, {
|
||||
userEventTriggered: this.userEventTriggered,
|
||||
let TextWebSocketFrameHandlerAdapterImpl = Java.extend(SimpleChannelInboundHandler, {
|
||||
userEventTriggered: this.userEventTriggered.bind(this),
|
||||
acceptInboundMessage: (msg: any) => {
|
||||
return TextWebSocketFrameMatcher.match(msg)
|
||||
},
|
||||
channelRead0: this.channelRead0
|
||||
channelRead0: this.channelRead0.bind(this)
|
||||
})
|
||||
this._Handler = new TextWebSocketFrameHandlerAdapterImpl();
|
||||
}
|
||||
abstract userEventTriggered(ctx: any, evt: any);
|
||||
abstract channelRead0(ctx: any, msg: any);
|
||||
|
@ -1,15 +1,14 @@
|
||||
const MiaoWebSocket = 'miaowebsocket'
|
||||
const CharsetUtil = Java.type('io.netty.util.CharsetUtil')
|
||||
const ChannelInboundHandlerAdapter = Java.type('io.netty.channel.ChannelInboundHandlerAdapter')
|
||||
|
||||
export default abstract class WebSocketHandlerAdapter {
|
||||
export abstract class WebSocketHandlerAdapter {
|
||||
private _Handler;
|
||||
constructor() {
|
||||
this._Handler = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
channelRead: this.channelRead
|
||||
let ChannelInboundHandlerAdapterImpl = Java.extend(ChannelInboundHandlerAdapter, {
|
||||
channelRead: this.channelRead.bind(this)
|
||||
})
|
||||
this._Handler = new ChannelInboundHandlerAdapterImpl()
|
||||
}
|
||||
abstract channelRead(ctx: any, msg: any);
|
||||
abstract channelRead(ctx: any, channel: any);
|
||||
getHandler() {
|
||||
return this._Handler;
|
||||
}
|
||||
|
Reference in New Issue
Block a user