Skip to content

Commit

Permalink
add websocket stream check before sending a message (#15369)
Browse files Browse the repository at this point in the history
* Add WebSocket stream check before sending a message

Signed-off-by: Oleksii Orel <oorel@redhat.com>
  • Loading branch information
olexii4 committed Dec 2, 2019
1 parent 3f01e0d commit d719643
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dashboard/src/components/api/json-rpc/websocket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export class WebsocketClient implements ICommunicationClient {
* @param data to be sent
*/
send(data: any): void {
this.websocketStream.send(data);
if (this.websocketStream) {
this.websocketStream.send(data);
} else {
console.log('Failed to send data. WebSocket stream isn\'t open.');
}
}

/**
Expand Down

0 comments on commit d719643

Please sign in to comment.