fix: disable server error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-03-31 14:53:23 +08:00
parent a2c3eff622
commit ec65d00f28
7 changed files with 21 additions and 15 deletions

View File

@ -17,12 +17,6 @@ interface ServerOptions extends SocketIO.ServerOptions {
root?: string;
}
const defaultOptions: ServerOptions = {
event: new EventEmitter(),
path: '/socket.io',
root: root + '/wwwroot'
}
class Server implements SocketIO.Server {
private nettyServer: NettyWebSocketServer;
private allClients: { [key: string]: Client };
@ -43,7 +37,11 @@ class Server implements SocketIO.Server {
this.nsps = {};
this.sockets = new Namespace('/', this);
this.nsps['/'] = this.sockets;
this.initNettyServer(pipeline, Object.assign(defaultOptions, options));
this.initNettyServer(pipeline, Object.assign({
event: new EventEmitter(),
path: '/socket.io',
root: root + '/wwwroot'
}, options));
}
checkRequest(req: any, fn: (err: any, success: boolean) => void): void {

View File

@ -39,10 +39,10 @@ export class Parser {
return '4"encode error"'
}
}
console.debug(`encoded ${origin} as ${str}`);
console.trace(`encoded ${origin} as ${str}`);
return str;
}
tryStringify(str) {
tryStringify(str: any) {
try {
return JSON.stringify(str);
} catch (e) {
@ -136,11 +136,11 @@ export class Parser {
}
}
console.debug(`decoded ${str} as ${JSON.stringify(p)}`);
console.trace(`decoded ${str} as ${JSON.stringify(p)}`);
return p;
}
tryParse(str) {
tryParse(str: string) {
try {
return JSON.parse(str);
} catch (e) {