@ -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 {
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user