Skip to content

Commit

Permalink
fix: make handle message event lambda method
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra committed May 14, 2021
1 parent e141ebf commit 05bff39
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/transport/WsOutboundTransporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class WsOutboundTransporter implements OutboundTransporter {
this.agent = agent
this.logger = agent.injectionContainer.resolve(Symbols.Logger)
}

public async start(): Promise<void> {
// Nothing required to start WS
}
Expand Down Expand Up @@ -68,7 +69,9 @@ export class WsOutboundTransporter implements OutboundTransporter {
return socket
}

private handleMessageEvent(event: any) {
// NOTE: Because this method is passed to the event handler this must be a lambda method
// so 'this' is scoped to the 'WsOutboundTransporter' class instance
private handleMessageEvent = (event: any) => {
this.logger.debug('WebSocket message event received.', { url: event.target.url, data: event.data })
this.agent.receiveMessage(JSON.parse(event.data))
}
Expand Down

0 comments on commit 05bff39

Please sign in to comment.