Package net.tomp2p.rpc

Examples of net.tomp2p.rpc.DispatchHandler


   *
   * @param bufferedMessage the message of the requester to the unreachable peer that was buffered at the
   *            relay peer.
   */
  private void processMessage(Message bufferedMessage) {
    DispatchHandler handler = peer.connectionBean().dispatcher().associatedHandler(bufferedMessage);
    if (handler == null) {
      // ignore the message
      LOG.error("Cannot find the associated handler to message {}", bufferedMessage);
      return;
    }

    try {
      LOG.debug("Handle buffered message {}", bufferedMessage);
      handler.handleResponse(bufferedMessage, null, false, new AndroidDirectResponder(bufferedMessage));
    } catch (Exception e) {
      LOG.error("Cannot handle the buffered message {}", bufferedMessage, e);
    }
  }
View Full Code Here


            public void responseFireAndForget() {
        responderToRelay.responseFireAndForget();
            }
        };
       
        DispatchHandler dispatchHandler = dispatcher().associatedHandler(realMessage);
        if(dispatchHandler == null) {
          responder.failed(Type.EXCEPTION, "handler not found, probably not relaying peer anymore");
        } else {
          dispatchHandler.handleResponse(realMessage, null, false, responder);
        }
    }
View Full Code Here

            ctx.fireChannelRead(message);
            return;
        }

        Responder responder = new DirectResponder(ctx, message);
        final DispatchHandler myHandler = associatedHandler(message);
        if (myHandler != null) {
            boolean isUdp = ctx.channel() instanceof DatagramChannel;
            LOG.debug("about to respond to {}", message);
            PeerConnection peerConnection = new PeerConnection(message.sender(), new DefaultChannelPromise(ctx.channel()).setSuccess(), heartBeatMillis);
            myHandler.forwardMessage(message, isUdp ? null : peerConnection, responder);
        } else {
          //do better error handling, if a handler is not present at all, print a warning
          if(ioHandlers.isEmpty()) {
            LOG.debug("No handler found for {}. Probably we have shutdown this peer.", message);
          } else {
View Full Code Here

    if (recipient.peerId().isZero() && message.command() == RPC.Commands.PING.getNr()) {
      Number160 peerId = peerBeanMaster.serverPeerAddress().peerId();
      return searchHandler(peerId, peerId, RPC.Commands.PING.getNr());
      // else we search for the handler that we are responsible for
    } else {
      DispatchHandler handler = searchHandler(recipient.peerId(), recipient.peerId(), message.command());
      if (handler != null) {
        return handler;
      }

      // if we could not find a handler that we are responsible for, we
View Full Code Here

     */
    public Map<Number320, DispatchHandler> searchHandler(final Integer command) {
      Map<Number320, DispatchHandler> result = new HashMap<Number320, DispatchHandler>();
      for(Map.Entry<Number320, Map<Integer, DispatchHandler>> entry:ioHandlers.entrySet()) {
        for(Map.Entry<Integer, DispatchHandler> entry2:entry.getValue().entrySet()) {
          DispatchHandler handlerh = entry.getValue().get(command);
          if(handlerh!=null && entry2.getKey().equals(command)) {
            result.put(entry.getKey(), handlerh);
          }
        }
      }
View Full Code Here

TOP

Related Classes of net.tomp2p.rpc.DispatchHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.