public final class RealSubscriptionManager extends java.lang.Object implements SubscriptionManager
SubscriptionManager.Callback<T>| Constructor and Description |
|---|
RealSubscriptionManager(com.apollographql.apollo.response.ScalarTypeAdapters scalarTypeAdapters,
SubscriptionTransport.Factory transportFactory,
SubscriptionConnectionParamsProvider connectionParams,
java.util.concurrent.Executor dispatcher,
long connectionHeartbeatTimeoutMs,
com.apollographql.apollo.api.internal.Supplier<ResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>>> responseNormalizer,
boolean autoPersistSubscription) |
| Modifier and Type | Method and Description |
|---|---|
void |
addOnStateChangeListener(OnSubscriptionManagerStateChangeListener onStateChangeListener)
Adds new listener for subscription manager state changes.
|
SubscriptionManagerState |
getState()
Returns the current state of subscription manager.
|
void |
removeOnStateChangeListener(OnSubscriptionManagerStateChangeListener onStateChangeListener)
Removes listener for subscription manager state changes.
|
void |
start()
Set the
RealSubscriptionManager to a connectible state. |
void |
stop()
Unsubscribe from all active subscriptions, and disconnect the web socket.
|
<T> void |
subscribe(com.apollographql.apollo.api.Subscription<?,T,?> subscription,
SubscriptionManager.Callback<T> callback)
Starts provided subscription.
|
void |
unsubscribe(com.apollographql.apollo.api.Subscription subscription)
Stops provided subscription.
|
public RealSubscriptionManager(@NotNull
com.apollographql.apollo.response.ScalarTypeAdapters scalarTypeAdapters,
@NotNull
SubscriptionTransport.Factory transportFactory,
@NotNull
SubscriptionConnectionParamsProvider connectionParams,
@NotNull
java.util.concurrent.Executor dispatcher,
long connectionHeartbeatTimeoutMs,
@NotNull
com.apollographql.apollo.api.internal.Supplier<ResponseNormalizer<java.util.Map<java.lang.String,java.lang.Object>>> responseNormalizer,
boolean autoPersistSubscription)
public <T> void subscribe(@NotNull
com.apollographql.apollo.api.Subscription<?,T,?> subscription,
@NotNull
SubscriptionManager.Callback<T> callback)
SubscriptionManagersubscribe in interface SubscriptionManagersubscription - to startcallback - to be called on resultpublic void unsubscribe(@NotNull
com.apollographql.apollo.api.Subscription subscription)
SubscriptionManagerunsubscribe in interface SubscriptionManagersubscription - to stoppublic void start()
RealSubscriptionManager to a connectible state. It is safe to call this method
at any time. Does nothing unless we are in the stopped state.start in interface SubscriptionManagerpublic void stop()
SubscriptionManager is stopping
because we check the state in #doSubscribe(Subscription, Callback). We pass true to
disconnect(boolean) because we want to disconnect even if, somehow, a new subscription
is added while or after we are doing the doUnsubscribe(Subscription) loop.stop in interface SubscriptionManagerpublic SubscriptionManagerState getState()
SubscriptionManagergetState in interface SubscriptionManagerpublic void addOnStateChangeListener(@NotNull
OnSubscriptionManagerStateChangeListener onStateChangeListener)
SubscriptionManageraddOnStateChangeListener in interface SubscriptionManageronStateChangeListener - to be called when state changedpublic void removeOnStateChangeListener(@NotNull
OnSubscriptionManagerStateChangeListener onStateChangeListener)
SubscriptionManagerremoveOnStateChangeListener in interface SubscriptionManageronStateChangeListener - to remove