Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update server.js to fix [email protected] breaking changes #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ app._initializeWSS = function(server) {
// Create WebSocket server as well.
this._wss = new WebSocketServer({ path: path, server: server});

this._wss.on('connection', function(socket) {
this._wss.on('connection', function(socket, req) {
socket.upgradeReq = req;
var query = url.parse(socket.upgradeReq.url, true).query;
Copy link

@lpinca lpinca May 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the only place where upgradeReq is used it is probably better to use:

var query = url.parse(req ? req.url : socket.upgradeReq.url, true).query;

and remove the previous line. This will work with all ws versions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the ws dependency version to 3.0.0 as well.

Thanks.

var id = query.id;
var token = query.token;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"body-parser": "^1.9.0",
"express": "^4.9.8",
"optimist": "~0.6.1",
"ws": "*",
"ws": "^3.0.0",
"cors": "~2.5.0"
},
"devDependencies": {
Expand Down