@ChannelHandler.Sharable
public class DispatcherReply
extends org.jboss.netty.channel.SimpleChannelHandler
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!
Constructor and Description |
---|
DispatcherReply(int p2pID,
PeerBean peerBean,
ConnectionConfiguration configuration,
org.jboss.netty.channel.group.ChannelGroup channelGroup,
PeerMap peerMap)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ChannelStateEvent e) |
void |
exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.ExceptionEvent e)
Called if we get an exception
|
void |
messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
org.jboss.netty.channel.MessageEvent e)
Called if we get a message
|
void |
registerIoHandler(Number160 localPeerId,
ReplyHandler ioHandler,
Message.Command... names)
Registers a handler with this dispatcher.
|
void |
removeIoHandler(Number160 localPeerId)
If we shutdown, we remove the handlers.
|
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, handleUpstream, setInterestOpsRequested, unbindRequested, writeComplete, writeRequested
public DispatcherReply(int p2pID, PeerBean peerBean, ConnectionConfiguration configuration, org.jboss.netty.channel.group.ChannelGroup channelGroup, PeerMap peerMap)
p2pID
- the p2p ID the dispatcher is looking for in messagesrouting
- public void registerIoHandler(Number160 localPeerId, ReplyHandler ioHandler, Message.Command... names)
sender
- Specifies the receiver the dispatcher filters for. This allows
to use one dispatcher for several interfaces or even nodes.
TODO: why call it sender here if it really acts as receiver?name
- The command of the Message
the given handler
processes. All messages having that command will be forwarded
to the given handler.ioHandler
- the handler which should process the given type of messagespublic void removeIoHandler(Number160 localPeerId)
id
- The Id of the peer to remove the handlers.public void channelOpen(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ChannelStateEvent e) throws Exception
channelOpen
in class org.jboss.netty.channel.SimpleChannelHandler
Exception
public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
exceptionCaught
in class org.jboss.netty.channel.SimpleChannelHandler
Copyright © 2013. All Rights Reserved.