@Override public void run() { //Cancel subscription only if in Active state. synchronized (this) { switch (state.get()) { case IDLE: { state.set(CANCELED); break; } case ACTIVE: { try { subscriptionManager.unsubscribe(subscription); subscriptionManager.removeListener(subscription, userCallback); userCallback.onCompleted(); userCallback = null; } finally { state.set(CANCELED); } break; } case CANCELED: // These are not illegal states, but cancelling does nothing break; default: throw new IllegalStateException("Unknown state"); } } } }).start();
if (subscriptionCallback != null ) { Log.v(TAG, "Delta Sync: Propagating queued message on subscription"); subscriptionCallback.onResponse(r);
@Override public void run() { //Cancel subscription only if in Active state. synchronized (this) { switch (state.get()) { case IDLE: { state.set(CANCELED); break; } case ACTIVE: { try { subscriptionManager.unsubscribe(subscription); subscriptionManager.removeListener(subscription, userCallback); userCallback.onCompleted(); userCallback = null; } finally { state.set(CANCELED); } break; } case CANCELED: // These are not illegal states, but cancelling does nothing break; default: throw new IllegalStateException("Unknown state"); } } } }).start();
private void notifyDisconnectionEventToAllListeners() { for (AppSyncSubscriptionCall.Callback listener : listeners) { //Let all listeners know the connection was disconnected. listener.onCompleted(); } }
private void notifyErrorToAllListeners(ApolloException e) { for (AppSyncSubscriptionCall.Callback listener : listeners) { listener.onFailure(e); } } }
private void propagateMessageToAllListeners(Response<T> data) { for (AppSyncSubscriptionCall.Callback listener : listeners) { Log.v(TAG, "Propagating message to : " + listener.toString()); listener.onResponse(data); } }