Search in sources :

Example 1 with CreateSessionMessage

use of net.i2p.data.i2cp.CreateSessionMessage in project i2p.i2p by i2p.

the class I2CPMessageProducer method connect.

/**
 * Send all the messages that a client needs to send to a router to establish
 * a new session.
 */
public void connect(I2PSessionImpl session) throws I2PSessionException {
    updateBandwidth(session);
    CreateSessionMessage msg = new CreateSessionMessage();
    SessionConfig cfg = new SessionConfig(session.getMyDestination());
    cfg.setOptions(session.getOptions());
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("config created");
    try {
        cfg.signSessionConfig(session.getPrivateKey());
    } catch (DataFormatException dfe) {
        throw new I2PSessionException("Unable to sign the session config", dfe);
    }
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("config signed");
    msg.setSessionConfig(cfg);
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("config loaded into message");
    session.sendMessage_unchecked(msg);
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("config message sent");
}
Also used : DataFormatException(net.i2p.data.DataFormatException) SessionConfig(net.i2p.data.i2cp.SessionConfig) I2PSessionException(net.i2p.client.I2PSessionException) CreateSessionMessage(net.i2p.data.i2cp.CreateSessionMessage)

Aggregations

I2PSessionException (net.i2p.client.I2PSessionException)1 DataFormatException (net.i2p.data.DataFormatException)1 CreateSessionMessage (net.i2p.data.i2cp.CreateSessionMessage)1 SessionConfig (net.i2p.data.i2cp.SessionConfig)1