Package net.tomp2p.p2p.builder

Examples of net.tomp2p.p2p.builder.BootstrapBuilder


  }

  private boolean bootstrap(Peer peer) throws UnknownHostException {
    // bootstrap
    InetAddress bootstrapTo = InetAddress.getLocalHost();
    BootstrapBuilder bootstrapBuilder = peer.bootstrap().inetAddress(bootstrapTo).ports(RELAY_START_PORT);
    BaseFuture bootstrap = bootstrapBuilder.start().awaitUninterruptibly();

    if (bootstrap == null) {
      LOG.error("Cannot bootstrap");
      return false;
    } else if (bootstrap.isFailed()) {
View Full Code Here


  public static void main(String[] args) throws IOException {
    final Number160 idP1 = Number160.createHash("p1");
    final Number160 idP2 = Number160.createHash("p2");
    PeerDHT p1 = new PeerBuilderDHT(new PeerBuilder(idP1).ports(1234).start()).start();
    PeerDHT p2 = new PeerBuilderDHT(new PeerBuilder(idP2).ports(1235).start()).start();
    BootstrapBuilder b = p2.peer().bootstrap();
    b.bootstrapTo(Arrays.asList(new PeerAddress(idP1, "localhost", 1234, 1234)));
    b.start().awaitUninterruptibly();

    p1.peer().objectDataReply(new ObjectDataReply() {
      @Override
      public Object reply(PeerAddress sender, Object request) throws Exception {
        if (sender.peerId().equals(idP2)) {
View Full Code Here

    public SendDirectBuilder sendDirect(PeerConnection peerConnection) {
        return new SendDirectBuilder(this, peerConnection);
    }

    public BootstrapBuilder bootstrap() {
        return new BootstrapBuilder(this);
    }
View Full Code Here

      }
    };
  }

  public FutureRelayNAT startRelay(final PeerAddress peerAddress) {
    final BootstrapBuilder bootstrapBuilder = peer.bootstrap().peerAddress(peerAddress);
    return startRelay(bootstrapBuilder);
  }
View Full Code Here

      public void operationComplete(FutureDiscover future) throws Exception {
        if (future.isFailed()) {
          if (futureNAT != null) {
            handleFutureNat(futureDiscover.reporter(), futureNAT, futureRelayNAT);
          } else {
            BootstrapBuilder bootstrapBuilder = peer.bootstrap().peerAddress(futureDiscover.reporter());
            startRelay(futureRelayNAT, bootstrapBuilder);
          }
        } else {
          futureRelayNAT.done();
        }
View Full Code Here

      public void operationComplete(FutureNAT future) throws Exception {
        if (future.isSuccess()) {
          // setup UPNP or NATPMP worked
          futureRelayNAT.done();
        } else {
          BootstrapBuilder bootstrapBuilder = peer.bootstrap().peerAddress(peerAddress);
          startRelay(futureRelayNAT, bootstrapBuilder);
        }
      }
    });
  }
View Full Code Here

TOP

Related Classes of net.tomp2p.p2p.builder.BootstrapBuilder

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.