feat: optimize framework add error catch(only log)

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-03-24 13:27:11 +08:00
parent 1ea8966f26
commit b71ce1b24d
10 changed files with 191 additions and 99 deletions

View File

@@ -9,6 +9,7 @@ import { PacketTypes, SubPacketTypes } from './types';
const parser = new Parser();
export class Client extends EventEmitter implements SocketIO.Client {
id: string;
server: Server;
conn: NettyClient;
request: any;
@@ -20,13 +21,11 @@ export class Client extends EventEmitter implements SocketIO.Client {
super();
this.server = server;
this.conn = nettyClient;
this.id = this.conn.id + '';
this.request = nettyClient.request;
this.sockets = {};
this.nsps = {};
}
get id() {
return this.conn.id;
}
connect(name, query) {
if (this.server.nsps[name]) {
// console.debug(`connecting to namespace ${name}`);
@@ -63,7 +62,7 @@ export class Client extends EventEmitter implements SocketIO.Client {
}
});
}
packet(packet: Packet) {
packet(packet: Packet, opts?: any) {
this.conn.send(parser.encode(packet))
}
onclose(reason: string) {