Package freenet.io.comm

Examples of freenet.io.comm.Message


  }

  public long startSendAnnouncementRequest(long uid, PeerNode peer, byte[] noderef, ByteCounter ctr,
      double target, short htl) throws NotConnectedException {
    long xferUID = node.random.nextLong();
    Message msg = DMT.createFNPOpennetAnnounceRequest(uid, xferUID, noderef.length,
        paddedSize(noderef.length), target, htl);
    peer.sendAsync(msg, null, ctr);
    return xferUID;
  }
View Full Code Here


      Logger.error(this, "Noderef too big: "+noderef.length+" bytes");
      return;
    }
    System.arraycopy(noderef, 0, padded, 0, noderef.length);
    long xferUID = node.random.nextLong();
    Message msg = DMT.createFNPOpennetAnnounceReply(uid, xferUID, noderef.length,
        padded.length);
    peer.sendAsync(msg, null, ctr);
    innerSendOpennetRef(xferUID, padded, peer, ctr, null);
  }
View Full Code Here

    byte[] noderef = Arrays.copyOf(buf, realLength);
    return noderef;
  }

  public static void rejectRef(long uid, PeerNode source, int reason, ByteCounter ctr) {
    Message msg = DMT.createFNPOpennetNoderefRejected(uid, reason);
    try {
      source.sendAsync(msg, null, ctr);
    } catch (NotConnectedException e) {
      // Ignore
    }
View Full Code Here

  * Low-level ping this node.
  * @return True if we received a reply inside 2000ms.
  * (If we have heavy packet loss, it can take that long to resend).
  */
  public boolean ping(int pingID) throws NotConnectedException {
    Message ping = DMT.createFNPPing(pingID);
    node.usm.send(this, ping, node.dispatcher.pingCounter);
    Message msg;
    try {
      msg = node.usm.waitFor(MessageFilter.create().setTimeout(2000).setType(DMT.FNPPong).setField(DMT.PING_SEQNO, pingID), null);
    } catch(DisconnectedException e) {
      throw new NotConnectedException("Disconnected while waiting for pong");
    }
View Full Code Here

  * Send any high level messages that need to be sent on connect.
  */
  protected void sendInitialMessages() {
    loadSender(true).setSendASAP();
    loadSender(false).setSendASAP();
    Message locMsg = DMT.createFNPLocChangeNotificationNew(node.lm.getLocation(), node.peers.getPeerLocationDoubles(true));
    Message ipMsg = DMT.createFNPDetectedIPAddress(detectedPeer);
    Message timeMsg = DMT.createFNPTime(System.currentTimeMillis());
    Message dRoutingMsg = DMT.createRoutingStatus(!disableRoutingHasBeenSetLocally);
    Message uptimeMsg = DMT.createFNPUptime((byte)(int)(100*node.uptime.getUptime()));

    try {
      if(isRealConnection())
        sendAsync(locMsg, null, node.nodeStats.initialMessagesCtr);
      sendAsync(ipMsg, null, node.nodeStats.initialMessagesCtr);
View Full Code Here

      node.nodeUpdater.maybeSendUOMAnnounce(this);
    sendConnectedDiffNoderef();
  }

  private void sendIPAddressMessage() {
    Message ipMsg = DMT.createFNPDetectedIPAddress(detectedPeer);
    try {
      sendAsync(ipMsg, null, node.nodeStats.changedIPCtr);
    } catch(NotConnectedException e) {
      Logger.normal(this, "Sending IP change message to " + this + " but disconnected: " + e, e);
    }
View Full Code Here

  /** Offer a key to this node */
  public void offer(Key key) {
    byte[] keyBytes = key.getFullKey();
    // FIXME maybe the authenticator should be shorter than 32 bytes to save memory?
    byte[] authenticator = HMAC.macWithSHA256(node.failureTable.offerAuthenticatorKey, keyBytes, 32);
    Message msg = DMT.createFNPOfferKey(key, authenticator);
    try {
      sendAsync(msg, null, node.nodeStats.sendOffersCtr);
    } catch(NotConnectedException e) {
    // Ignore
    }
View Full Code Here

    fs.putOverwrite("n2nType", Integer.toString(n2nType));
    if(includeSentTime) {
      fs.put("sentTime", now);
    }
    try {
      Message n2nm;
      n2nm = DMT.createNodeToNodeMessage(
          n2nType, fs.toString().getBytes("UTF-8"));
      try {
        sendAsync(n2nm, null, node.nodeStats.nodeToNodeCounter);
      } catch (NotConnectedException e) {
View Full Code Here

  }

  private void tryFetchRevocation(final PeerNode source) throws NotConnectedException {
    // Try to transfer it.

    Message msg = DMT.createUOMRequestRevocation(updateManager.node.random.nextLong());
    source.sendAsync(msg, new AsyncMessageCallback() {

      @Override
      public void acknowledged() {
        // Ok
View Full Code Here

      fetchingUOM = true;
    }
    if(!wasFetchingUOM)
      this.updateManager.onStartFetchingUOM();

    Message msg =
      DMT.createUOMRequestMainJar(updateManager.node.random.nextLong());

    try {
      System.err.println("Fetching "+lname+" jar from " + source.userToString());
      source.sendAsync(msg, new AsyncMessageCallback() {
View Full Code Here

TOP

Related Classes of freenet.io.comm.Message

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.