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

feat: OkHttp implementation for making HTTP calls and WebSocket connections #1035

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
fix: integration tests for OkHttp realtime tests
ttypic committed Oct 3, 2024
commit 1d04fc487d798c5b584dbdffa5b8f3739bfd395c
13 changes: 12 additions & 1 deletion lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ public class WebSocketTransport implements ITransport {
private ConnectListener connectListener;
private WebSocketClient webSocketClient;
private final WebSocketEngine webSocketEngine;
private boolean activityCheckTurnedOff = false;

/******************
* protected constructor
@@ -173,6 +174,16 @@ protected void preProcessReceivedMessage(ProtocolMessage message) {
//Gives the chance to child classes to do message pre-processing
}

/**
* Visible For Testing
* </p>
* We need to turn off activity check for some tests (e.g. io.ably.lib.test.realtime.RealtimeConnectFailTest.disconnect_retry_channel_timeout_jitter_after_consistent_detach[binary_protocol])
* Those tests expects that activity checks are passing, but protocol messages are not coming
*/
protected void turnOffActivityCheckIfPingListenerIsNotSupported() {
if (!webSocketEngine.isPingListenerSupported()) activityCheckTurnedOff = true;
}

public String toString() {
return WebSocketTransport.class.getName() + " {" + getURL() + "}";
}
@@ -319,7 +330,7 @@ private synchronized void dispose() {
private synchronized void flagActivity() {
lastActivityTime = System.currentTimeMillis();
connectionManager.setLastActivity(lastActivityTime);
if (activityTimerTask == null && connectionManager.maxIdleInterval != 0) {
if (activityTimerTask == null && connectionManager.maxIdleInterval != 0 && !activityCheckTurnedOff) {
/* No timer currently running because previously there was no
* maxIdleInterval configured, but now there is a
* maxIdleInterval configured. Call checkActivity so a timer
Original file line number Diff line number Diff line change
@@ -155,6 +155,7 @@ private MockWebsocketTransport(TransportParams givenTransportParams, TransportPa
super(transformedTransportParams, connectionManager);
this.givenTransportParams = givenTransportParams;
this.transformedTransportParams = transformedTransportParams;
turnOffActivityCheckIfPingListenerIsNotSupported();
}

public List<ProtocolMessage> getSentMessages() {