T - The message type.public interface Protocol<T>
A protocol implementation. A protocol is a stage in a bi-directional messaging pipeline. It can receive incoming and outgoing messages. In response to these messages, it can dispatch incoming and outgoing messages. It can also register callbacks to be executed later, to allow timeouts and periodic behaviour to be implemented.
All methods on protocol are called from a single thread at a time, so implementations do not have to use any locking for their state. The method implementations should not block.
| Modifier and Type | Method and Description |
|---|---|
void |
handleIncoming(T message)
Handles an incoming message.
|
void |
handleOutgoing(T message)
Handles an outgoing message.
|
void |
start(ProtocolContext<T> context)
Called to initialise the protocol.
|
void |
stopRequested()
Requests that this protocol initiate its stop messages.
|
void start(ProtocolContext<T> context)
context - The context.void handleOutgoing(T message)
void handleIncoming(T message)
void stopRequested()
ProtocolContext.stopLater() to defer stop until some
messages are received. In which case, it should later call ProtocolContext.stopped() to indicate it has finished.
If the protocol does not call stopLater(), it is assumed to have stopped when this method returns.Copyright © 2013. All rights reserved