Skip to content

Commit

Permalink
Update to 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
Stefan Becker committed Nov 8, 2017
1 parent 1162186 commit 3e41b4c
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 3e41b4c

Please sign in to comment.