Skip to content

Commit

Permalink
fix: correct scope in handleUpgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Aug 15, 2020
1 parent 44c20c4 commit 0fbd09e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/src/websocket-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export class WebSocketServer extends EventEmitter {

wss.on('connection', (socket) => {
const connectionId = connectionCounter++
console.log(`Websocket connection received (connectionId: ${connectionId})`)
const log = (...args) => console.log(`(connectionId: ${connectionId})`, ...args)

log('Websocket connection received')

socket.on('message', (data: string) => {
const parsed: CommandFrame = JSON.parse(data)
Expand All @@ -30,8 +32,6 @@ export class WebSocketServer extends EventEmitter {
}

handleUpgrade = (request, socket, head) => {
this.wss.handleUpgrade(request, socket, head, function done(ws) {
this.wss.emit('connection', ws)
})
this.wss.handleUpgrade(request, socket, head, (ws) => this.wss.emit('connection', ws))
}
}

0 comments on commit 0fbd09e

Please sign in to comment.