@ChannelHandler.Sharable public class Dispatcher extends io.netty.channel.SimpleChannelInboundHandler<Message>
registerIoHandler function.
You probably want to add an instance of this class to the end of a pipeline to be able to receive messages. This class is able to cover several channels but only one P2P network!
| Modifier and Type | Class and Description |
|---|---|
class |
Dispatcher.DirectResponder |
| Constructor and Description |
|---|
Dispatcher(int p2pID,
PeerBean peerBean,
int heartBeatMillis)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
Message message) |
DispatchHandler |
getAssociatedHandler(Message message)
Checks if we have a handler for the given message.
|
void |
registerIoHandler(Number160 peerId,
DispatchHandler ioHandler,
int... names)
Registers a handler with this dispatcher.
|
void |
removeIoHandler(Number160 peerId)
If we shutdown, we remove the handlers.
|
Map<Number160,DispatchHandler> |
searchHandler(Integer command)
May take longer..
|
DispatchHandler |
searchHandler(Number160 recipientID,
Integer command)
Looks for a registered handler according to the given parameters.
|
acceptInboundMessage, channelReadchannelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredhandlerAdded, handlerRemoved, isSharablepublic Dispatcher(int p2pID,
PeerBean peerBean,
int heartBeatMillis)
p2pID - the p2p ID the dispatcher is looking for in messagespeerBean - .public void registerIoHandler(Number160 peerId, DispatchHandler ioHandler, int... names)
peerId - Specifies the receiver the dispatcher filters for. This allows to use one dispatcher for several
interfaces or even nodes.ioHandler - the handler which should process the given type of messagesnames - The command of the Message the given handler processes. All messages having that command will
be forwarded to the given handler.public void removeIoHandler(Number160 peerId)
peerId - The Id of the peer to remove the handlers .protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx,
Message message)
throws Exception
public DispatchHandler getAssociatedHandler(Message message)
message - the message a handler should be found forpublic DispatchHandler searchHandler(Number160 recipientID, Integer command)
recipientID - The recipient of the messagecommand - The type of the message to be filteredpublic Map<Number160,DispatchHandler> searchHandler(Integer command)
command - Copyright © 2014. All rights reserved.