feat: update plugin & websocket

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-04-24 16:42:36 +08:00
parent e9c13e44b4
commit 1431ce0a6e
2 changed files with 7 additions and 8 deletions

View File

@ -1,10 +1,10 @@
import { EventEmitter } from 'events'
import { NettyClient } from './client'
import { ServerOptions } from '../socket-io'
import { ServerEvent, Keys } from './constants'
import { WebSocketDetect } from './websocket_detect'
import { WebSocketHandler } from './websocket_handler'
import { NettyClient } from './client'
import { ServerOptions } from '../socket-io'
class NettyWebSocketServer extends EventEmitter {
private pipeline: any;
@ -22,10 +22,9 @@ class NettyWebSocketServer extends EventEmitter {
ctx.fireChannelRead(channel)
})
connectEvent.on(ServerEvent.connect, (ctx) => {
console.log('NettyWebSocketServer ServerEvent.connect', ctx, ctx.channel().id(), ctx.channel().class.name)
let nettyClient = new NettyClient(this, ctx.channel());
this.allClients[nettyClient.id] = nettyClient;
this.emit(ServerEvent.connect, nettyClient);
let nettyClient = new NettyClient(this, ctx.channel())
this.allClients[nettyClient.id] = nettyClient
this.emit(ServerEvent.connect, nettyClient)
})
connectEvent.on(ServerEvent.message, (ctx, msg) => {
this.emit(ServerEvent.message, this.allClients[ctx.channel().id()], msg.text())
@ -46,4 +45,4 @@ export {
NettyWebSocketServer,
ServerEvent,
NettyClient
};
}

View File

@ -1,7 +1,7 @@
import { TextWebSocketFrameHandlerAdapter } from '../netty'
import { EventEmitter } from 'events'
import { ServerEvent } from './constants'
import { ServerOptions } from '../socket-io';
import { TextWebSocketFrameHandlerAdapter } from '../netty'
export class TextWebSocketFrameHandler extends TextWebSocketFrameHandlerAdapter {
private event: EventEmitter;