Skip to content

Commit 51bc6de

Browse files
author
Max Presman
committed
reconnection policies maximum retries + affected ch, cg
1 parent a2a75c3 commit 51bc6de

28 files changed

Lines changed: 280 additions & 17 deletions

‎src/main/java/com/pubnub/api/PNConfiguration.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ public class PNConfiguration {
113113
@Setter
114114
private PNReconnectionPolicy reconnectionPolicy;
115115

116+
/**
117+
* Set how many times the reconneciton manager will try to connect before giving app
118+
*/
119+
@Setter
120+
private int maximumReconnectionRetries;
121+
116122
/**
117123
* Proxy configuration which will be passed to the networking layer.
118124
*/
@@ -161,6 +167,8 @@ public PNConfiguration() {
161167

162168
startSubscriberThread = true;
163169

170+
maximumReconnectionRetries = -1;
171+
164172
}
165173

166174
/**

‎src/main/java/com/pubnub/api/callbacks/ReconnectionCallback.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ public abstract class ReconnectionCallback {
55

66
public abstract void onReconnection();
77

8+
public abstract void onMaxReconnectionExhaustion();
9+
810
}

‎src/main/java/com/pubnub/api/endpoints/Endpoint.java‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,9 @@ protected Map<String, String> createBaseParams() {
302302
return params;
303303
}
304304

305-
protected List<String> getAffectedChannels() {
306-
return null;
307-
}
305+
protected abstract List<String> getAffectedChannels();
308306

309-
protected List<String> getAffectedChannelGroups() {
310-
return null;
311-
}
307+
protected abstract List<String> getAffectedChannelGroups();
312308

313309
protected abstract void validateParams() throws PubNubException;
314310

‎src/main/java/com/pubnub/api/endpoints/FetchMessages.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ public FetchMessages(PubNub pubnub, Retrofit retrofit) {
4545
maximumPerChannel = 1;
4646
}
4747

48+
@Override
49+
protected List<String> getAffectedChannels() {
50+
return channels;
51+
}
52+
53+
@Override
54+
protected List<String> getAffectedChannelGroups() {
55+
return null;
56+
}
57+
4858
private interface HistoryForChannelsService {
4959
@GET("v3/history/sub-key/{subKey}/channel/{channels}")
5060
Call<FetchMessagesEnvelope> fetchMessages(@Path("subKey") String subKey,

‎src/main/java/com/pubnub/api/endpoints/History.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import retrofit2.http.QueryMap;
2121

2222
import java.util.ArrayList;
23+
import java.util.Collections;
2324
import java.util.Iterator;
2425
import java.util.List;
2526
import java.util.Map;
@@ -44,6 +45,16 @@ public History(PubNub pubnub, Retrofit retrofit) {
4445
super(pubnub, retrofit);
4546
}
4647

48+
@Override
49+
protected List<String> getAffectedChannels() {
50+
return Collections.singletonList(channel);
51+
}
52+
53+
@Override
54+
protected List<String> getAffectedChannelGroups() {
55+
return null;
56+
}
57+
4758
private interface HistoryService {
4859
@GET("v2/history/sub-key/{subKey}/channel/{channel}")
4960
Call<JsonElement> fetchHistory(@Path("subKey") String subKey,

‎src/main/java/com/pubnub/api/endpoints/Time.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ public Time(PubNub pubnub, Retrofit retrofit) {
2020
super(pubnub, retrofit);
2121
}
2222

23+
@Override
24+
protected List<String> getAffectedChannels() {
25+
return null;
26+
}
27+
28+
@Override
29+
protected List<String> getAffectedChannelGroups() {
30+
return null;
31+
}
32+
2333
private interface TimeService {
2434
@GET("/time/0")
2535
Call<List<Long>> fetchTime(@QueryMap Map<String, String> options);

‎src/main/java/com/pubnub/api/endpoints/access/Audit.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import retrofit2.Retrofit;
1717

1818
import java.util.ArrayList;
19+
import java.util.Collections;
1920
import java.util.List;
2021
import java.util.Map;
2122

@@ -34,6 +35,16 @@ public Audit(PubNub pubnub, Retrofit retrofit) {
3435
authKeys = new ArrayList<>();
3536
}
3637

38+
@Override
39+
protected List<String> getAffectedChannels() {
40+
return Collections.singletonList(channel);
41+
}
42+
43+
@Override
44+
protected List<String> getAffectedChannelGroups() {
45+
return Collections.singletonList(channelGroup);
46+
}
47+
3748
@Override
3849
protected void validateParams() throws PubNubException {
3950
if (authKeys.size() == 0) {

‎src/main/java/com/pubnub/api/endpoints/access/Grant.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ public Grant(PubNub pubnub, Retrofit retrofit) {
5252
channelGroups = new ArrayList<>();
5353
}
5454

55+
@Override
56+
protected List<String> getAffectedChannels() {
57+
return channels;
58+
}
59+
60+
@Override
61+
protected List<String> getAffectedChannelGroups() {
62+
return channelGroups;
63+
}
64+
5565
@Override
5666
protected void validateParams() throws PubNubException {
5767
if (this.getPubnub().getConfiguration().getSecretKey() == null || this.getPubnub().getConfiguration().getSecretKey().isEmpty()) {

‎src/main/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import retrofit2.Retrofit;
1616

1717
import java.util.ArrayList;
18+
import java.util.Collections;
1819
import java.util.List;
1920
import java.util.Map;
2021

@@ -31,6 +32,16 @@ public AddChannelChannelGroup(PubNub pubnub, Retrofit retrofit) {
3132
channels = new ArrayList<>();
3233
}
3334

35+
@Override
36+
protected List<String> getAffectedChannels() {
37+
return channels;
38+
}
39+
40+
@Override
41+
protected List<String> getAffectedChannelGroups() {
42+
return Collections.singletonList(channelGroup);
43+
}
44+
3445
@Override
3546
protected void validateParams() throws PubNubException {
3647
if (channelGroup == null || channelGroup.isEmpty()) {

‎src/main/java/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public AllChannelsChannelGroup(PubNub pubnub, Retrofit retrofit) {
2626
super(pubnub, retrofit);
2727
}
2828

29+
@Override
30+
protected List<String> getAffectedChannels() {
31+
return null;
32+
}
33+
34+
@Override
35+
protected List<String> getAffectedChannelGroups() {
36+
return null;
37+
}
38+
2939
@Override
3040
protected void validateParams() throws PubNubException {
3141
if (channelGroup == null || channelGroup.isEmpty()) {

0 commit comments

Comments
 (0)