Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
niyatim23 committed Apr 15, 2024
1 parent e0ed1b2 commit a44d095
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,19 @@ on:
- master
jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
java: [11, 17]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
distribution: 'corretto'
java-version: ${{ matrix.java }}

- name: Download libwebrtc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class SignalingListener implements Signaling {
private final WebSocketListener websocketListener = new WebSocketListener() {

@Override
public void onMessage(@NonNull WebSocket webSocket, String message) {
public void onMessage(@NonNull final WebSocket webSocket, @NonNull final String message) {
if (message.isEmpty()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ class WebSocketClient {
private final WebSocket webSocket;
private volatile boolean isOpen = false;

WebSocketClient(final String uri, final SignalingListener signalingListener) {
WebSocketClient(@NonNull final String uri, @NonNull final SignalingListener signalingListener) {

OkHttpClient client = new OkHttpClient.Builder().build();

String userAgent = (Constants.APP_NAME + "/" + Constants.VERSION + " " + System.getProperty("http.agent")).trim();

Log.d(TAG, "User agent: " + userAgent);

Request request = new Request.Builder()
.url(uri)
.addHeader("User-Agent", Constants.APP_NAME + "/" + Constants.VERSION
+ " " + System.getProperty("http.agent"))
.addHeader("User-Agent", userAgent)
.build();

webSocket = client.newWebSocket(request, new WebSocketListener() {
Expand Down Expand Up @@ -78,11 +81,11 @@ void send(String message) {

void disconnect() {
if (isOpen) {
if (!webSocket.close(1000, "Disconnect requested")) {
if (webSocket.close(1000, "Disconnect requested")) {
Log.d(TAG, "Websocket successfully disconnected.");
} else {
Log.d(TAG, "Websocket could not disconnect in a graceful shutdown. Going to cancel it to release resources.");
webSocket.cancel();
} else {
Log.d(TAG, "Websocket successfully disconnected.");
}
} else {
Log.d(TAG, "Cannot close the websocket as it is not open.");
Expand Down

0 comments on commit a44d095

Please sign in to comment.