Skip to content

Commit

Permalink
Update Android websocket module to expose onOpen callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkcsc authored and Flewp committed Jan 17, 2023
1 parent ade0849 commit 7caed29
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public interface ContentHandler {
void onMessage(ByteString byteString, WritableMap params);
}

public interface OnOpenHandler {

void onOpen(final WebSocket webSocket, final int socketId);
}

public @Nullable OnOpenHandler mOnOpenHandler = null;

private final Map<Integer, WebSocket> mWebSocketConnections = new ConcurrentHashMap<>();
private final Map<Integer, ContentHandler> mContentHandlers = new ConcurrentHashMap<>();

Expand Down Expand Up @@ -162,6 +169,10 @@ public void onOpen(WebSocket webSocket, Response response) {
params.putInt("id", id);
params.putString("protocol", response.header("Sec-WebSocket-Protocol", ""));
sendEvent("websocketOpen", params);

if (mOnOpenHandler != null) {
mOnOpenHandler.onOpen(webSocket, id);
}
}

@Override
Expand Down

0 comments on commit 7caed29

Please sign in to comment.