Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(transcription): Stop websocket in new thread as recommended. #567

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.client.*;
import org.jitsi.jigasi.util.*;
import org.jitsi.utils.logging.*;

import java.io.*;
Expand Down Expand Up @@ -58,6 +59,11 @@ public class OracleRealtimeClient
private final static Logger logger
= Logger.getLogger(OracleRealtimeClient.class);

/**
* The thread pool to serve all connect, disconnect ore reconnect operations.
*/
private static final ExecutorService threadPool = Util.createNewThreadPool("jigasi-oracle-ws");

/**
* Constructor.
*
Expand All @@ -83,20 +89,23 @@ public OracleRealtimeClient(
@OnWebSocketClose
public void onClose(int statusCode, String reason)
{
String closedBy = isClosureClientInitiated ? "client" : "server";
logger.info("Session closed by " + closedBy + ", reason = " + reason + ", status code = " + statusCode);
isConnected = false;
this.session = null;
try
{
this.client.stop();
}
catch (Exception e)
threadPool.submit(() ->
{
logger.error("Error while stopping the OCI transcription client: ", e);
}
//The listener can implement their own closing logic
this.listener.onClose(statusCode, reason);
String closedBy = isClosureClientInitiated ? "client" : "server";
logger.info("Session closed by " + closedBy + ", reason = " + reason + ", status code = " + statusCode);
isConnected = false;
this.session = null;
try
{
this.client.stop();
}
catch (Exception e)
{
logger.error("Error while stopping the OCI transcription client: ", e);
}
//The listener can implement their own closing logic
this.listener.onClose(statusCode, reason);
});
}

/**
Expand Down
Loading