Skip to content

Commit

Permalink
fix(WebSockerServer): Send responses more robustly
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Nov 7, 2019
1 parent e76bd80 commit ec0252c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ws/WebSocketServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ export class WebSocketConnection implements Connection {
return Promise.resolve()
}

/**
* Send a response using the Websocket
*
* Will wait until the socket is open before
* attempting to send the data.
*/
public send(data: string) {
send(this.socket, data)
}

/**
* @implements Implements {@link Connection.stop} by closing the WebSocket.
*/
Expand Down Expand Up @@ -115,7 +125,7 @@ export class WebSocketServer extends HttpServer {
id: wsconnection.id
}
})
if (response !== undefined) socket.send(response)
if (response !== undefined) wsconnection.send(response)
})

// Handle any errors
Expand Down

0 comments on commit ec0252c

Please sign in to comment.