Package org.yamcs.client.base
Class AbstractSubscription<C extends com.google.protobuf.Message,S extends com.google.protobuf.Message>
- java.lang.Object
-
- org.yamcs.client.base.AbstractSubscription<C,S>
-
- All Implemented Interfaces:
Future<Void>,Subscription<C,S>
- Direct Known Subclasses:
AlarmSubscription,ClearanceSubscription,CommandSubscription,EventSubscription,GlobalAlarmStatusSubscription,LinkSubscription,PacketSubscription,ParameterSubscription,ProcessorSubscription,QueueEventSubscription,QueueStatisticsSubscription,TimeSubscription
public abstract class AbstractSubscription<C extends com.google.protobuf.Message,S extends com.google.protobuf.Message> extends Object implements Subscription<C,S>
Default base class for aSubscription.This is designed such that most subclasses need only to provide type information. More advanced subscription subclasses may want to add custom functionality such as call-specific message processing.
-
-
Field Summary
Fields Modifier and Type Field Description protected Observer<C>clientObserver
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSubscription(MethodHandler methodHandler, String topic, Class<S> responseClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMessageListener(MessageListener<S> listener)Get updated on received server messages.voidawaitConfirmation()Waits until the server has confirmed the call for this subscription.voidawaitConfirmation(long timeout, TimeUnit unit)Waits until the server has confirmed the call for this subscription.booleancancel(boolean mayInterruptIfRunning)Cancel this subscription.Voidget()Voidget(long timeout, TimeUnit unit)CompletableFuture<Void>getConfirmationFuture()booleanisCancelled()booleanisDone()voidsendMessage(C message)Send a message (typically a subscription request) to Yamcs
-
-
-
Constructor Detail
-
AbstractSubscription
protected AbstractSubscription(MethodHandler methodHandler, String topic, Class<S> responseClass)
-
-
Method Detail
-
sendMessage
public void sendMessage(C message)
Send a message (typically a subscription request) to Yamcs- Specified by:
sendMessagein interfaceSubscription<C extends com.google.protobuf.Message,S extends com.google.protobuf.Message>
-
addMessageListener
public void addMessageListener(MessageListener<S> listener)
Get updated on received server messages.- Specified by:
addMessageListenerin interfaceSubscription<C extends com.google.protobuf.Message,S extends com.google.protobuf.Message>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
Cancel this subscription. After this method is called, you will no longer receive any messages from it.
-
getConfirmationFuture
public CompletableFuture<Void> getConfirmationFuture()
-
awaitConfirmation
public void awaitConfirmation() throws InterruptedException, ExecutionExceptionWaits until the server has confirmed the call for this subscription. Only the first client message of a call is confirmed.
-
awaitConfirmation
public void awaitConfirmation(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutExceptionWaits until the server has confirmed the call for this subscription. Only the first client message of a call is confirmed.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<C extends com.google.protobuf.Message>
-
isDone
public boolean isDone()
-
get
public Void get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<C extends com.google.protobuf.Message>- Throws:
InterruptedExceptionExecutionException
-
get
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<C extends com.google.protobuf.Message>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
-