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
,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 protected
AbstractSubscription(MethodHandler methodHandler, String topic, Class<S> responseClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMessageListener(MessageListener<S> listener)
Get updated on received server messages.boolean
cancel(boolean mayInterruptIfRunning)
Cancel this subscription.Void
get()
Void
get(long timeout, TimeUnit unit)
boolean
isCancelled()
boolean
isDone()
void
sendMessage(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:
sendMessage
in 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:
addMessageListener
in 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.
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<C extends com.google.protobuf.Message>
-
isDone
public boolean isDone()
-
get
public Void get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<C extends com.google.protobuf.Message>
- Throws:
InterruptedException
ExecutionException
-
get
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
get
in interfaceFuture<C extends com.google.protobuf.Message>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
-