Increasing the message ids of the SubscriptionMessagesHub increase monotonically
This commit is contained in:
parent
e5ce587f68
commit
c8fe1ec9c4
4 changed files with 9 additions and 7 deletions
|
@ -17,7 +17,7 @@
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
# org.gradle.parallel=true
|
# org.gradle.parallel=true
|
||||||
|
|
||||||
VERSION_NAME=0.4.6-alpha0
|
VERSION_NAME=0.4.6-alpha1
|
||||||
VERSION_CODE=8
|
VERSION_CODE=8
|
||||||
GROUP=com.github.bilthon
|
GROUP=com.github.bilthon
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ android {
|
||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
targetSdkVersion 24
|
targetSdkVersion 24
|
||||||
versionCode 8
|
versionCode 8
|
||||||
versionName "0.4.6-alpha0"
|
versionName "0.4.6-alpha1"
|
||||||
|
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,17 +140,17 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
|
||||||
String message = frame.getPayloadText();
|
String message = frame.getPayloadText();
|
||||||
System.out.println("<< "+message);
|
System.out.println("<< "+message);
|
||||||
if(currentId == LOGIN_ID){
|
if(currentId == LOGIN_ID){
|
||||||
|
currentId = GET_DATABASE_ID;
|
||||||
ArrayList<Serializable> emptyParams = new ArrayList<>();
|
ArrayList<Serializable> emptyParams = new ArrayList<>();
|
||||||
ApiCall getDatabaseId = new ApiCall(1, RPC.CALL_DATABASE, emptyParams, RPC.VERSION, currentId);
|
ApiCall getDatabaseId = new ApiCall(1, RPC.CALL_DATABASE, emptyParams, RPC.VERSION, currentId);
|
||||||
websocket.sendText(getDatabaseId.toJsonString());
|
websocket.sendText(getDatabaseId.toJsonString());
|
||||||
currentId++;
|
|
||||||
}else if(currentId == GET_DATABASE_ID){
|
}else if(currentId == GET_DATABASE_ID){
|
||||||
Type ApiIdResponse = new TypeToken<WitnessResponse<Integer>>() {}.getType();
|
Type ApiIdResponse = new TypeToken<WitnessResponse<Integer>>() {}.getType();
|
||||||
WitnessResponse<Integer> witnessResponse = gson.fromJson(message, ApiIdResponse);
|
WitnessResponse<Integer> witnessResponse = gson.fromJson(message, ApiIdResponse);
|
||||||
databaseApiId = witnessResponse.result;
|
databaseApiId = witnessResponse.result;
|
||||||
|
|
||||||
subscribe();
|
subscribe();
|
||||||
} else if(currentId == SUBSCRIPTION_REQUEST){
|
} else if(currentId >= SUBSCRIPTION_REQUEST){
|
||||||
List<SubscriptionListener> subscriptionListeners = mSubscriptionDeserializer.getSubscriptionListeners();
|
List<SubscriptionListener> subscriptionListeners = mSubscriptionDeserializer.getSubscriptionListeners();
|
||||||
|
|
||||||
if(!isUnsubscribing){
|
if(!isUnsubscribing){
|
||||||
|
@ -204,12 +204,12 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
|
||||||
private void subscribe(){
|
private void subscribe(){
|
||||||
isUnsubscribing = false;
|
isUnsubscribing = false;
|
||||||
|
|
||||||
|
currentId++;
|
||||||
ArrayList<Serializable> subscriptionParams = new ArrayList<>();
|
ArrayList<Serializable> subscriptionParams = new ArrayList<>();
|
||||||
subscriptionParams.add(String.format("%d", SUBSCRIPTION_NOTIFICATION));
|
subscriptionParams.add(String.format("%d", SUBSCRIPTION_NOTIFICATION));
|
||||||
subscriptionParams.add(clearFilter);
|
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());
|
mWebsocket.sendText(getDatabaseId.toJsonString());
|
||||||
currentId = SUBSCRIPTION_REQUEST;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,7 +235,8 @@ public class SubscriptionMessagesHub extends BaseGrapheneHandler implements Subs
|
||||||
isSubscribed = false;
|
isSubscribed = false;
|
||||||
isUnsubscribing = true;
|
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());
|
mWebsocket.sendText(unsubscribe.toJsonString());
|
||||||
|
|
||||||
// Clearing all subscription listeners
|
// Clearing all subscription listeners
|
||||||
|
|
|
@ -20,6 +20,7 @@ import cy.agorise.graphenej.models.SubscriptionResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used to encapsulate all tests that relate to the {@see SubscriptionMessagesHub} class.
|
* 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 {
|
public class SubscriptionMessagesHubTest extends BaseApiTest {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue