Skip to content

Instantly share code, notes, and snippets.

@Zensey
Created August 4, 2016 18:21
Show Gist options
  • Save Zensey/04d3964f4cb8d54215ac4c3a12ca7a13 to your computer and use it in GitHub Desktop.
Save Zensey/04d3964f4cb8d54215ac4c3a12ca7a13 to your computer and use it in GitHub Desktop.
function *noop(){}
Ws.prototype.onConnection = function *(client) {
try {
var ctx = this.web.koa_app.createContext(client.upgradeReq, {statusCode: null});
yield this.web.session_.bind(ctx)(noop);
var sessionId = ctx.sessionId;
this.logger.info("WebSocket.onConnection", sessionId);
...
}
...
}
...
Ws.prototype.init = function *() {
var wss = new WebSocketServer({server: this.koa.httpsServer});
wss.on('connection', co.wrap(this.onConnection).bind(this))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment