Package net.tomp2p.message

Examples of net.tomp2p.message.Message.buffer()


      } else if(!gcmServerCredentials.valid()) {
        LOG.error("GCM Server Configuration is not valid. Please provide a valid configuration");
        return futureDone.failed("Invalid GCM configuration");
      } else {
        // add the registration ID, the GCM authentication key and the map update interval
        message.buffer(RelayUtils.encodeString(gcmServerCredentials.registrationId()));
        message.buffer(RelayUtils.encodeString(gcmServerCredentials.senderAuthenticationKey()));
        message.intValue(mapUpdateInterval);
      }
    }
View Full Code Here


        LOG.error("GCM Server Configuration is not valid. Please provide a valid configuration");
        return futureDone.failed("Invalid GCM configuration");
      } else {
        // add the registration ID, the GCM authentication key and the map update interval
        message.buffer(RelayUtils.encodeString(gcmServerCredentials.registrationId()));
        message.buffer(RelayUtils.encodeString(gcmServerCredentials.senderAuthenticationKey()));
        message.intValue(mapUpdateInterval);
      }
    }

    LOG.debug("Setting up relay connection to peer {}, message {}", candidate, message);
View Full Code Here

    LOG.debug("Sending {} to unreachable peer {}", message, peerConnection.remotePeer());
    final Message envelope = createMessage(peerConnection.remotePeer(), RPC.Commands.RELAY.getNr(), Type.REQUEST_2);
    try {
      message.restoreContentReferences();
      // add the message into the payload
      envelope.buffer(RelayUtils.encodeMessage(message, connectionBean().channelServer().channelServerConfiguration().signatureFactory()));
    } catch (Exception e) {
      LOG.error("Cannot encode the message", e);
      return new FutureDone<Message>().failed(e);
    }
View Full Code Here

    @Override
    public void response(final Message responseMessage) {
      // piggyback the late response. It will be unwrapped by the dispatcher
      Message envelope = dispatchHandler.createMessage(responseMessage.recipient(), Commands.RELAY.getNr(), Type.REQUEST_5);
      try {
        envelope.buffer(RelayUtils.encodeMessage(responseMessage, peer.connectionBean().channelServer().channelServerConfiguration().signatureFactory()));
      } catch (Exception e) {
        LOG.error("Cannot wrap the late response into an envelope", e);
        return;
      }
     
View Full Code Here

            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);
View Full Code Here

      AndroidForwarderRPC androidForwarder = (AndroidForwarderRPC) forwarderRPC;
     
      try {
        Message response = createResponseMessage(message, Type.OK);
        // add all buffered messages
        response.buffer(androidForwarder.getBufferedMessages());
       
        LOG.debug("Responding all buffered messages to Android device {}", message.sender());
        responder.response(response);
      } catch(Exception e) {
        LOG.error("Cannot respond with buffered messages.", e);
View Full Code Here

                } else if (replyBuffer != requestBuffer) {
                    // can be partial as well
                    if (!replyBuffer.isComplete()) {
                        responseMessage.streaming();
                    }
                    responseMessage.buffer(replyBuffer);
                }
            } else { // no streaming here when we deal with objects
                Object obj = Utils.decodeJavaObject(requestBuffer.buffer());
                LOG.debug("handling {}", obj);
View Full Code Here

                    responseMessage.type(Type.NOT_FOUND);
                } else if (reply == obj) {
                    responseMessage.type(Type.OK);
                } else {
                    byte[] me = Utils.encodeJavaObject(reply);
                    responseMessage.buffer(new Buffer(Unpooled.wrappedBuffer(me)));
                }
            }
        }
        responder.response(responseMessage);
    }
View Full Code Here

            message.publicKeyAndSign(sendDirectBuilder.keyPair());
        }
        message.streaming(sendDirectBuilder.isStreaming());

        if (sendDirectBuilder.isRaw()) {
            message.buffer(sendDirectBuilder.buffer());
        } else {
            byte[] me;
            try {
                me = Utils.encodeJavaObject(sendDirectBuilder.object());
                message.buffer(new Buffer(Unpooled.wrappedBuffer(me)));
View Full Code Here

            message.buffer(sendDirectBuilder.buffer());
        } else {
            byte[] me;
            try {
                me = Utils.encodeJavaObject(sendDirectBuilder.object());
                message.buffer(new Buffer(Unpooled.wrappedBuffer(me)));
            } catch (IOException e) {
                futureResponse.failed("cannot convert object", e);
            }      
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.