Skip to content

Commit ec9ca84

Browse files
committed
Upgrade ws to 5.x
There was one breaking change but didn't end up being that big of a deal. websockets/ws#1099
1 parent 7dac6c8 commit ec9ca84

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"sockjs": ">= 0.3.1",
2020
"socket.io": "2.5.0",
2121
"socket.io-client": "2.4.0",
22-
"ws": "2.3.1",
22+
"ws": "5.2.4",
2323
"request": ">= 2.1.1",
2424
"coffee-script": "1.7.0",
2525
"hat": "*"

src/server/websocket.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ sessionHandler = require('./session').handler
66
STATISTICS_INTERVAL = 10000 # 10 seconds
77
CLIENT_TIMEOUT = 30000 # 30 seconds
88

9-
wrapSession = (conn) ->
9+
wrapSession = (conn, req) ->
1010
wrapper = new EventEmitter
1111
wrapper.abort = -> conn.close()
1212
wrapper.stop = -> conn.close()
@@ -28,17 +28,17 @@ wrapSession = (conn) ->
2828
else
2929
wrapper.emit 'message', msg
3030

31-
wrapper.headers = conn.upgradeReq.headers
31+
wrapper.headers = req.headers
3232
# TODO - I don't think this is the right way to get the address
3333
wrapper.address = conn._socket.server._connectionKey?
3434
wrapper
3535

3636
exports.attach = (server, createAgent, options) ->
3737
options.prefix or= '/websocket'
3838
wss = new WebSocketServer {server: server, path: options.prefix, headers: options.headers}
39-
wss.on 'connection', (conn) ->
39+
wss.on 'connection', (conn, req) ->
4040
conn.isAlive = true
41-
sessionHandler wrapSession(conn), createAgent
41+
sessionHandler wrapSession(conn, req), createAgent
4242

4343
if !!options.trackStats
4444
setInterval ->

0 commit comments

Comments
 (0)