Package net.tomp2p.connection

Examples of net.tomp2p.connection.Responder


        realMessage.restoreContentReferences();

        LOG.debug("Received message from relay peer: {}", realMessage);
       
        final Message envelope = createResponseMessage(message, Type.OK);
        final Responder responder = new Responder() {
          //TODO: add reply leak handler
          @Override
          public void response(Message responseMessage) {
            LOG.debug("Send reply message to relay peer: {}", responseMessage);
            try {
              if(responseMessage.sender().isRelayed() && !responseMessage.sender().peerSocketAddresses().isEmpty()) {
                responseMessage.peerSocketAddresses(responseMessage.sender().peerSocketAddresses());
              }
              envelope.buffer(RelayUtils.encodeMessage(responseMessage, signatureFactory()));
                } catch (Exception e) {
                  LOG.error("Cannot piggyback the response", e);
                  failed(Type.EXCEPTION, e.getMessage());
                }
                responderToRelay.response(envelope);
          }

      @Override
            public void failed(Type type, String reason) {
        responderToRelay.failed(type, reason);
            }

      @Override
            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

TOP

Related Classes of net.tomp2p.connection.Responder

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.