Skip to content

Commit

Permalink
Upgrade ws to 5.x
Browse files Browse the repository at this point in the history
There was one breaking change but didn't end up being that big
of a deal.

websockets/ws#1099
  • Loading branch information
nickbrowne committed Nov 14, 2024
1 parent 7dac6c8 commit ec9ca84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"sockjs": ">= 0.3.1",
"socket.io": "2.5.0",
"socket.io-client": "2.4.0",
"ws": "2.3.1",
"ws": "5.2.4",
"request": ">= 2.1.1",
"coffee-script": "1.7.0",
"hat": "*"
Expand Down
8 changes: 4 additions & 4 deletions src/server/websocket.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sessionHandler = require('./session').handler
STATISTICS_INTERVAL = 10000 # 10 seconds
CLIENT_TIMEOUT = 30000 # 30 seconds

wrapSession = (conn) ->
wrapSession = (conn, req) ->
wrapper = new EventEmitter
wrapper.abort = -> conn.close()
wrapper.stop = -> conn.close()
Expand All @@ -28,17 +28,17 @@ wrapSession = (conn) ->
else
wrapper.emit 'message', msg

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

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

if !!options.trackStats
setInterval ->
Expand Down

0 comments on commit ec9ca84

Please sign in to comment.