Skip to content

Commit b5bb0b8

Browse files
author
Stefan Becker
committed
Changes for ws 3.x API
To reduce memory usage ws replaced the socket.updateReq property with 2nd argument to the connection event [1] [1] websockets/ws#1099
1 parent 1162186 commit b5bb0b8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ KoaWebSocketServer.prototype.listen = function (options) {
1818
this.server.on('connection', this.onConnection.bind(this));
1919
};
2020

21-
KoaWebSocketServer.prototype.onConnection = function(socket) {
21+
KoaWebSocketServer.prototype.onConnection = function(socket, request) {
2222
debug('Connection received');
2323
socket.on('error', function (err) {
2424
debug('Error occurred:', err);
2525
});
2626
const fn = co.wrap(compose(this.middleware));
2727

28-
const context = this.app.createContext(socket.upgradeReq);
28+
const context = this.app.createContext(request);
2929
context.websocket = socket;
30-
context.path = url.parse(socket.upgradeReq.url).pathname;
30+
context.path = url.parse(request.url).pathname;
3131

3232
fn(context).catch(function(err) {
3333
debug(err);

0 commit comments

Comments
 (0)