public abstract class DispatchHandler extends Object
| Constructor and Description |
|---|
DispatchHandler(PeerBean peerBean,
ConnectionBean connectionBean)
Creates a handler with a connection and peer bean.
|
| Modifier and Type | Method and Description |
|---|---|
ConnectionBean |
connectionBean() |
Message |
createMessage(PeerAddress recipient,
byte name,
Message.Type type)
Create a request message and fills it with connection bean and peer bean parameters.
|
Message |
createResponseMessage(Message requestMessage,
Message.Type replyType)
Create a response message and fills it with connection bean and peer bean parameters.
|
static Message |
createResponseMessage(Message requestMessage,
Message.Type replyType,
PeerAddress peerAddress) |
void |
forwardMessage(Message requestMessage,
PeerConnection peerConnection,
Responder responder)
Forwards the request to a handler.
|
abstract void |
handleResponse(Message message,
PeerConnection peerConnection,
boolean sign,
Responder responder)
If the message is OK, that has been previously checked by the user using checkMessage, a reply to the message is
generated here.
|
PeerBean |
peerBean() |
void |
register(int... names)
Registers all names on the dispatcher on behalf of the own peer
|
void |
register(Number160 onBehalfOf,
int... names)
Registers all names on the dispatcher on behalf of the given peer
|
void |
sign(boolean sign) |
public DispatchHandler(PeerBean peerBean, ConnectionBean connectionBean)
peerBean - The peer beanconnectionBean - The connection beannames - The command namespublic void register(int... names)
names - public void register(Number160 onBehalfOf, int... names)
onBehalfOf - The ioHandler can be registered for the own use of in behalf of another peer (e.g. in case of relay node).names - public void sign(boolean sign)
sign - Set to true if message is signedpublic PeerBean peerBean()
public ConnectionBean connectionBean()
public Message createMessage(PeerAddress recipient, byte name, Message.Type type)
recipient - The recipient of this messagename - The commend typetype - The request typepublic Message createResponseMessage(Message requestMessage, Message.Type replyType)
requestMessage - The request messagereplyType - The type of the replypublic static Message createResponseMessage(Message requestMessage, Message.Type replyType, PeerAddress peerAddress)
public void forwardMessage(Message requestMessage, PeerConnection peerConnection, Responder responder)
requestMessage - The request messagepeerConnection - The peer connection that can be used for communicationresponder - public abstract void handleResponse(Message message, PeerConnection peerConnection, boolean sign, Responder responder) throws Exception
message - Request messagepeerConnection - sign - Flag to indicate if message is signedresponder2 - responder - Exception - Any exceptionCopyright © 2014. All rights reserved.