Tabnine Logo
SessionId
Code IndexAdd Tabnine to your IDE (free)

How to use
SessionId
in
net.i2p.data.i2cp

Best Java code snippets using net.i2p.data.i2cp.SessionId (Showing top 20 results out of 315)

origin: i2p/i2p.i2p

@Override
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
  SessionId id = new SessionId();
  try {
    id.readBytes(in);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Unable to load the message data", dfe);
  }
  setSessionId(id);
}
origin: i2p/i2p.i2p

/**
 * try hard to make a decent identifier as this will appear in error logs
 */
protected String getPrefix() {
  StringBuilder buf = new StringBuilder();
  buf.append('[');
  buf.append(_state.toString()).append(' ');
  String s = _options.getProperty("inbound.nickname");
  if (s != null)
    buf.append(s);
  else
    buf.append(getClass().getSimpleName());
  SessionId id = _sessionId;
  if (id != null)
    buf.append(" #").append(id.getSessionId());
  buf.append("]: ");
  return buf.toString();
}
origin: i2p/i2p.i2p

/**
 *  Return the dest for the given ID
 *  @return dest or null if unknown
 *  @since 0.9.21
 */
public Destination getDestination(SessionId id) {
  if (id == null)
    return null;
  for (SessionParams sp : _sessions.values()) {
    if (id.equals(sp.sessionId))
      return sp.dest;
  }
  return null;
}

origin: i2p/i2p.i2p

public DataStructure createDataStructure() throws DataFormatException {
  SessionId id = new SessionId();
  id.setSessionId(7);
  return id;
}
public DataStructure createStructureToRead() { return new SessionId(); }
origin: i2p/i2p.i2p

/**
 * Return the SessionId for this message.
 *
 * @since 0.9.21
 */
@Override
public SessionId sessionId() {
  return _sessionId >= 0 ? new SessionId(_sessionId) : null;
}
origin: i2p/i2p.i2p

SessionId id = message.sessionId();
SessionId currId = _sessionId;
if (id == null || id.equals(currId) ||
  (currId == null && id != null && type == SessionStatusMessage.MESSAGE_TYPE) ||
  ((id == null || id.getSessionId() == 65535) &&
   (type == HostReplyMessage.MESSAGE_TYPE || type == DestReplyMessage.MESSAGE_TYPE))) {
          id = sess.getSessionId();
          if (id != null) {
            if (id.equals(_sessionId)) {
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

/**
 * Return the SessionId for this message.
 *
 * @since 0.9.21
 */
@Override
public SessionId sessionId() {
  return _sessionId >= 0 ? new SessionId(_sessionId) : null;
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("No data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(256);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _endpoints.size());
    for (int i = 0; i < _endpoints.size(); i++) {
      _endpoints.get(i).writeBytes(os);
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
  try {
    _sessionId = new SessionId();
    _sessionId.readBytes(in);
    _status = (int) DataHelper.readLong(in, 1);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Unable to load the message data", dfe);
  }
}
origin: i2p/i2p.i2p

/**
 * Return the SessionId for this message.
 *
 * @since 0.9.21
 */
@Override
public SessionId sessionId() {
  return _sessionId >= 0 ? new SessionId(_sessionId) : null;
}
origin: i2p/i2p.i2p

  /**
   *  Deliver the message directly, skip notification
   *  @since 0.9.4
   */
  private void sendMessage(long id) throws I2CPMessageException {
    MessagePayloadMessage msg = new MessagePayloadMessage();
    msg.setMessageId(id);
    SessionId sid = _runner.getSessionId(_toDest.calculateHash());
    if (sid == null) {
      if (_log.shouldLog(Log.WARN))
        _log.warn("No session for " + _toDest.calculateHash());
      return;
    }
    msg.setSessionId(sid.getSessionId());
    msg.setPayload(_payload);
    _runner.doSend(msg);
  }
}
origin: i2p/i2p.i2p

/**
 *  Current client's config,
 *  will be null if session not found
 *  IS subsession aware.
 *  Returns null if id is null.
 *  @since 0.9.21 added id param
 */
public SessionConfig getConfig(SessionId id) {
  if (id == null)
    return null;
  for (SessionParams sp : _sessions.values()) {
    if (id.equals(sp.sessionId))
      return sp.config;
  }
  return null;
}

origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null || _sessionConfig == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
    _sessionConfig.writeBytes(os);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}
origin: i2p/i2p.i2p

@Override
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
  try {
    _sessionId = new SessionId();
    _sessionId.readBytes(in);
    _sessionConfig = new SessionConfig();
    _sessionConfig.readBytes(in);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Unable to load the message data", dfe);
  }
}
origin: i2p/i2p.i2p

/**
 * Return the SessionId for this message.
 *
 * @since 0.9.21
 */
@Override
public SessionId sessionId() {
  return _sessionId >= 0 ? new SessionId(_sessionId) : null;
}
origin: i2p/i2p.i2p

/** 
 * Send a notification to the client that their message (id specified) was accepted 
 * for delivery (but not necessarily delivered)
 * Doesn't do anything if i2cp.messageReliability = "none"
 * or if the nonce is 0.
 *
 * @param id OUR id for the message
 * @param nonce HIS id for the message
 */
void ackSendMessage(SessionId sid, MessageId id, long nonce) {
  if (_dontSendMSM || nonce == 0)
    return;
  if (_log.shouldLog(Log.DEBUG))
    _log.debug("Acking message send [accepted]" + id + " / " + nonce + " for sessionId " 
          + sid);
  MessageStatusMessage status = new MessageStatusMessage();
  status.setMessageId(id.getMessageId()); 
  status.setSessionId(sid.getSessionId());
  status.setSize(0L);
  status.setNonce(nonce);
  status.setStatus(MessageStatusMessage.STATUS_SEND_ACCEPTED);
  try {
    doSend(status);
    _acceptedPending.remove(id);
  } catch (I2CPMessageException ime) {
    if (_log.shouldLog(Log.WARN))
      _log.warn("Error writing out the message status message", ime);
  }
}

origin: i2p/i2p.i2p

/**
 *  Return the hash for the given ID
 *  @return hash or null if unknown
 *  @since 0.9.21
 */
public Hash getDestHash(SessionId id) {
  if (id == null)
    return null;
  for (Map.Entry<Hash, SessionParams> e : _sessions.entrySet()) {
    if (id.equals(e.getValue().sessionId))
      return e.getKey();
  }
  return null;
}
origin: i2p/i2p.i2p

@Override
protected byte[] doWriteMessage() throws I2CPMessageException, IOException {
  if (_sessionId == null)
    throw new I2CPMessageException("Unable to write out the message as there is not enough data");
  ByteArrayOutputStream os = new ByteArrayOutputStream(64);
  try {
    _sessionId.writeBytes(os);
    DataHelper.writeLong(os, 1, _status);
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Error writing out the message data", dfe);
  }
  return os.toByteArray();
}

origin: i2p/i2p.i2p

@Override
protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException {
  try {
    if (_sessionId != null)
      throw new IllegalStateException();
    _sessionId = new SessionId();
    _sessionId.readBytes(in);
    int numTunnels = (int) DataHelper.readLong(in, 1);
    for (int i = 0; i < numTunnels; i++) {
      Lease lease = new Lease();
      lease.readBytes(in);
      _endpoints.add(lease);
    }
  } catch (DataFormatException dfe) {
    throw new I2CPMessageException("Unable to load the message data", dfe);
  }
}
net.i2p.data.i2cpSessionId

Javadoc

Defines the token passed between the router and client to associate messages with a particular session. These IDs are not globally unique.

Most used methods

  • <init>
  • getSessionId
  • equals
  • readBytes
  • setSessionId
  • writeBytes

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • putExtra (Intent)
  • getSystemService (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Vector (java.util)
    Vector is an implementation of List, backed by an array and synchronized. All optional operations in
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now