Package net.tomp2p.message

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


    // making the message ready to send
    PeerAddress recipient = message.recipient().changeAddress(socketAddress.inetAddress())
            .changePorts(socketAddress.tcpPort(), socketAddress.udpPort()).changeRelayed(false);
    rconMessage.recipient(recipient);
    rconMessage.command(RPC.Commands.RCON.getNr());
    rconMessage.type(Message.Type.REQUEST_1);
    return rconMessage;
  }

  /**
   * This method is extracted by @author jonaswagner to ensure that no
View Full Code Here


  public static Message createRandomMessage() {
    Random rnd = new Random();

    Message message = new Message();
    message.command(Commands.values()[rnd.nextInt(Commands.values().length)].getNr());
    message.type(Type.values()[rnd.nextInt(Type.values().length)]);
    message.recipientSocket(new InetSocketAddress(0));
    message.recipient(new PeerAddress(new Number160(rnd), message.recipientSocket()));
    message.senderSocket(new InetSocketAddress(0));
    message.sender(new PeerAddress(new Number160(rnd), message.senderSocket()));
    return message;
View Full Code Here

        message.sender(n1);
        //
        PeerAddress n2 = createAddress(idRecipien, inetRecipient, tcpPortRecipient, udpPortRecipient,
                firewallUDP, firewallTCP);
        message.recipient(n2);
        message.type(type);
        message.command(command);
        return message;
    }

    public static PeerDHT[] createNodes(int nrOfPeers, Random rnd, int port) throws Exception {
View Full Code Here

        message.sender(n1);
        //
        PeerAddress n2 = createAddress(idRecipien, inetRecipient, tcpPortRecipient, udpPortRecipient,
                firewallUDP, firewallTCP);
        message.recipient(n2);
        message.type(type);
        message.command(command);
        return message;
    }

    public static PeerDHT[] createNodes(int nrOfPeers, Random rnd, int port) throws Exception {
View Full Code Here

      couldProvideMoreData = size > meshPeers.size();
      responseMessage.trackerData(meshPeers);
    }

    if (couldProvideMoreData) {
      responseMessage.type(Message.Type.PARTIALLY_OK);
    }

    if (message.command() == RPC.Commands.TRACKER_ADD.getNr()) {
      TrackerData trackerData = message.trackerData(0);
      if (trackerData.size() != 1) {
View Full Code Here

    }

    if (message.command() == RPC.Commands.TRACKER_ADD.getNr()) {
      TrackerData trackerData = message.trackerData(0);
      if (trackerData.size() != 1) {
        responseMessage.type(Message.Type.EXCEPTION);
      } else {
        Map.Entry<PeerStatistic, Data> entry = trackerData.peerAddresses().entrySet().iterator().next();
        if (!trackerStorage.put(new Number320(locationKey, domainKey), entry.getKey().peerAddress(), publicKey,
                entry.getValue())) {
          responseMessage.type(Message.Type.DENIED);
View Full Code Here

        responseMessage.type(Message.Type.EXCEPTION);
      } else {
        Map.Entry<PeerStatistic, Data> entry = trackerData.peerAddresses().entrySet().iterator().next();
        if (!trackerStorage.put(new Number320(locationKey, domainKey), entry.getKey().peerAddress(), publicKey,
                entry.getValue())) {
          responseMessage.type(Message.Type.DENIED);
          LOG.debug("tracker NOT put on({}) locationKey:{}, domainKey:{}, address:{}", peerBean()
                  .serverPeerAddress(), locationKey, domainKey, entry.getKey());
        } else {
          LOG.debug("tracker put on({}) locationKey:{}, domainKey:{}, address: {}", peerBean()
                  .serverPeerAddress(), locationKey, domainKey, entry.getKey());
View Full Code Here

      message.sender(n1);
      //
      PeerAddress n2 = createAddress(idRecipient, inetRecipient, tcpPortRecipient, udpPortRecipient,
              firewallUDP, firewallTCP);
      message.recipient(n2);
      message.type(type);
      message.command(command);
      return message;
  }

  public static PeerAddress createAddress(Number160 id) throws UnknownHostException {
View Full Code Here

                Object obj = Utils.decodeJavaObject(requestBuffer.buffer());
                LOG.debug("handling {}", obj);

                Object reply = objectDataReply2.reply(message.sender(), obj);
                if (reply == null) {
                    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)));
View Full Code Here

                Object reply = objectDataReply2.reply(message.sender(), obj);
                if (reply == null) {
                    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)));
                }
            }
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.