net.tomp2p.rpc
Class ReplyHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelHandler
      extended by net.tomp2p.rpc.ReplyHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelDownstreamHandler, org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler
Direct Known Subclasses:
DirectDataRPC, HandshakeRPC, NeighborRPC, PeerExchangeRPC, QuitRPC, StorageRPC, TaskRPC, TrackerRPC

public abstract class ReplyHandler
extends org.jboss.netty.channel.SimpleChannelHandler


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
ReplyHandler(PeerBean peerBean, ConnectionBean connectionBean)
           
 
Method Summary
abstract  boolean checkMessage(Message message)
          Before a reply can be done, the message needs to be checked.
 Message createMessage(PeerAddress recipient, Message.Command name, Message.Type type)
           
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
 Message forwardMessage(Message message)
           
abstract  Message handleResponse(Message message, boolean sign)
          If the message is OK, that has been previously checked by the user using checkMessage, a reply to the message is generated here.
protected  void registerIoHandler(Message.Command... names)
           
 void setSignReply(boolean sign)
           
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelHandler
bindRequested, channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, closeRequested, connectRequested, disconnectRequested, handleDownstream, handleUpstream, messageReceived, setInterestOpsRequested, unbindRequested, writeComplete, writeRequested
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReplyHandler

public ReplyHandler(PeerBean peerBean,
                    ConnectionBean connectionBean)
Method Detail

registerIoHandler

protected void registerIoHandler(Message.Command... names)

createMessage

public Message createMessage(PeerAddress recipient,
                             Message.Command name,
                             Message.Type type)

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelHandler

forwardMessage

public Message forwardMessage(Message message)

checkMessage

public abstract boolean checkMessage(Message message)
Before a reply can be done, the message needs to be checked. If you return false, then the peer is removed from the map and the channel is closed.

Parameters:
message - Request message
Returns:
True if a request should be generated, false if channel should be closed and nothing should be replied

handleResponse

public abstract Message handleResponse(Message message,
                                       boolean sign)
                                throws Exception
If the message is OK, that has been previously checked by the user using checkMessage, a reply to the message is generated here.

Parameters:
ch - Channel
message - Request message
Throws:
Exception

setSignReply

public void setSignReply(boolean sign)


Copyright © 2012. All Rights Reserved.