Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
niyatim23 committed Apr 10, 2024
1 parent 5cfb367 commit 35b96cf
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ public void onFailure(@NonNull WebSocket webSocket, @NonNull Throwable t, Respon

void send(String message) {
Log.d(TAG, "Sending message: " + message);
webSocket.send(message);
if (!webSocket.send(message)) {
Log.d(TAG, "Could not send " + message + " as the connection may have " +
"closing, closed, or canceled.");
}
}

void disconnect() {
webSocket.close(1000, "Disconnect requested");
if (!webSocket.close(1000, "Disconnect requested")) {
Log.d(TAG, "Websocket could not disconnect as a graceful shutdown was already " +
"underway or the web socket is already closed or canceled");
}
}

boolean isOpen() {
Expand Down

0 comments on commit 35b96cf

Please sign in to comment.