Skip to content

Commit

Permalink
Changes for ws 3.x API
Browse files Browse the repository at this point in the history
To reduce memory usage ws replaced the socket.updateReq property with
2nd argument to the connection event [1]

[1] websockets/ws#1099
  • Loading branch information
stefanb2 committed Nov 10, 2017
1 parent fa8e725 commit 9b6c2ba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ KoaWebSocketServer.prototype.listen = function (options) {
this.server.on('connection', this.onConnection.bind(this));
};

KoaWebSocketServer.prototype.onConnection = function(socket) {
KoaWebSocketServer.prototype.onConnection = function(socket, request) {
debug('Connection received');
socket.on('error', function (err) {
debug('Error occurred:', err);
});
const fn = co.wrap(compose(this.middleware));

const context = this.app.createContext(socket.upgradeReq);
const context = this.app.createContext(request);
context.websocket = socket;
context.path = url.parse(socket.upgradeReq.url).pathname;
context.path = url.parse(request.url).pathname;

fn(context).catch(function(err) {
debug(err);
Expand Down

0 comments on commit 9b6c2ba

Please sign in to comment.