Package net.tomp2p.message

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


    rconMessage.keepAlive(true);
    // 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;
  }

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

        //
        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 {
        return createNodes(nrOfPeers, rnd, port, null);
View Full Code Here

        //
        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 {
        return createNodes(nrOfPeers, rnd, port, null);
View Full Code Here

      //
      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 {
        return createAddress(id, "127.0.0.1", 8005, 8006, false, false);
View Full Code Here

      private Message createSetupMessage(final PeerAddress relayPeerAddress, final PeerAddress unreachablePeerAddress) {
        Message setUpMessage = new Message();
        setUpMessage.version(MESSAGE_VERSION);
        setUpMessage.sender(peer.peerAddress());
        setUpMessage.recipient(relayPeerAddress.changePeerId(unreachablePeerAddress.peerId()));
        setUpMessage.command(RPC.Commands.RCON.getNr());
        setUpMessage.type(Type.REQUEST_1);
        // setUpMessage.keepAlive(true);
        return setUpMessage;
      }
    });
View Full Code Here

        // this will have the ports > 40'000 that we need to know for sendig the reply
        replyMessage.senderSocket(requestMessage.senderSocket());
        replyMessage.recipientSocket(requestMessage.recipientSocket());
        replyMessage.recipient(requestMessage.sender());
        replyMessage.sender(peerAddress);
        replyMessage.command(requestMessage.command());
        replyMessage.type(replyType);
        replyMessage.version(requestMessage.version());
        replyMessage.messageId(requestMessage.messageId());
        replyMessage.udp(requestMessage.isUdp());
        return replyMessage;
View Full Code Here

          @Override
          public void run() {
            semaphore.release();
           
            Message request = futureResponse.request();
            if(request.recipient().isSlow() && request.command() != Commands.PING.getNr() && request.command() != Commands.NEIGHBOR.getNr()) {
              // If the request goes to a slow peer, the channel can be closed until the response arrives
              LOG.debug("Ignoring channel close event because recipient is slow peer");
            } else {
              futureResponse.responseNow();
            }
View Full Code Here

          @Override
          public void run() {
            semaphore.release();
           
            Message request = futureResponse.request();
            if(request.recipient().isSlow() && request.command() != Commands.PING.getNr() && request.command() != Commands.NEIGHBOR.getNr()) {
              // If the request goes to a slow peer, the channel can be closed until the response arrives
              LOG.debug("Ignoring channel close event because recipient is slow peer");
            } else {
              futureResponse.responseNow();
            }
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.