Increasing the message ids of the SubscriptionMessagesHub increase monotonically

This commit is contained in:
Nelson R. Perez 2017-11-09 15:08:35 -05:00
parent e5ce587f68
commit c8fe1ec9c4
4 changed files with 9 additions and 7 deletions

View file

@ -17,7 +17,7 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
VERSION_NAME=0.4.6-alpha0
VERSION_NAME=0.4.6-alpha1
VERSION_CODE=8
GROUP=com.github.bilthon

View file

@ -22,7 +22,7 @@ android {
minSdkVersion 9
targetSdkVersion 24
versionCode 8
versionName "0.4.6-alpha0"
versionName "0.4.6-alpha1"
vectorDrawables.useSupportLibrary = true
}

View file

@ -140,17 +140,17 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
String message = frame.getPayloadText();
System.out.println("<< "+message);
if(currentId == LOGIN_ID){
currentId = GET_DATABASE_ID;
ArrayList<Serializable> emptyParams = new ArrayList<>();
ApiCall getDatabaseId = new ApiCall(1, RPC.CALL_DATABASE, emptyParams, RPC.VERSION, currentId);
websocket.sendText(getDatabaseId.toJsonString());
currentId++;
}else if(currentId == GET_DATABASE_ID){
Type ApiIdResponse = new TypeToken<WitnessResponse<Integer>>() {}.getType();
WitnessResponse<Integer> witnessResponse = gson.fromJson(message, ApiIdResponse);
databaseApiId = witnessResponse.result;
subscribe();
} else if(currentId == SUBSCRIPTION_REQUEST){
} else if(currentId >= SUBSCRIPTION_REQUEST){
List<SubscriptionListener> subscriptionListeners = mSubscriptionDeserializer.getSubscriptionListeners();
if(!isUnsubscribing){
@ -204,12 +204,12 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
private void subscribe(){
isUnsubscribing = false;
currentId++;
ArrayList<Serializable> subscriptionParams = new ArrayList<>();
subscriptionParams.add(String.format("%d", SUBSCRIPTION_NOTIFICATION));
subscriptionParams.add(clearFilter);
ApiCall getDatabaseId = new ApiCall(databaseApiId, RPC.CALL_SET_SUBSCRIBE_CALLBACK, subscriptionParams, RPC.VERSION, SUBSCRIPTION_REQUEST);
ApiCall getDatabaseId = new ApiCall(databaseApiId, RPC.CALL_SET_SUBSCRIBE_CALLBACK, subscriptionParams, RPC.VERSION, currentId);
mWebsocket.sendText(getDatabaseId.toJsonString());
currentId = SUBSCRIPTION_REQUEST;
}
/**
@ -235,7 +235,8 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
isSubscribed = false;
isUnsubscribing = true;
ApiCall unsubscribe = new ApiCall(databaseApiId, RPC.CALL_CANCEL_ALL_SUBSCRIPTIONS, new ArrayList<Serializable>(), RPC.VERSION, SUBSCRIPTION_REQUEST);
currentId++;
ApiCall unsubscribe = new ApiCall(databaseApiId, RPC.CALL_CANCEL_ALL_SUBSCRIPTIONS, new ArrayList<Serializable>(), RPC.VERSION, currentId);
mWebsocket.sendText(unsubscribe.toJsonString());
// Clearing all subscription listeners

View file

@ -20,6 +20,7 @@ import cy.agorise.graphenej.models.SubscriptionResponse;
/**
* Class used to encapsulate all tests that relate to the {@see SubscriptionMessagesHub} class.
* This test requires setting up the NODE_URL environment variable
*/
public class SubscriptionMessagesHubTest extends BaseApiTest {