use of net.i2p.client.streaming.I2PSocketOptions in project i2p.i2p by i2p.
the class I2PTunnelClientBase method getDefaultOptions.
/**
* Create the default options (using the default timeout, etc).
* Warning, this does not make a copy of I2PTunnel's client options,
* it modifies them directly.
*/
protected I2PSocketOptions getDefaultOptions() {
Properties defaultOpts = getTunnel().getClientOptions();
I2PSocketOptions opts = sockMgr.buildOptions(defaultOpts);
if (!defaultOpts.containsKey(I2PSocketOptions.PROP_CONNECT_TIMEOUT))
opts.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT);
return opts;
}
use of net.i2p.client.streaming.I2PSocketOptions in project i2p.i2p by i2p.
the class I2PTunnelHTTPClient method getDefaultOptions.
/**
* Create the default options (using the default timeout, etc).
* Warning, this does not make a copy of I2PTunnel's client options,
* it modifies them directly.
* Do not use overrides for per-socket options.
*/
@Override
protected I2PSocketOptions getDefaultOptions(Properties overrides) {
Properties defaultOpts = getTunnel().getClientOptions();
defaultOpts.putAll(overrides);
if (!defaultOpts.contains(I2PSocketOptions.PROP_READ_TIMEOUT)) {
defaultOpts.setProperty(I2PSocketOptions.PROP_READ_TIMEOUT, "" + DEFAULT_READ_TIMEOUT);
}
if (!defaultOpts.contains("i2p.streaming.inactivityTimeout")) {
defaultOpts.setProperty("i2p.streaming.inactivityTimeout", "" + DEFAULT_READ_TIMEOUT);
}
// delayed start
verifySocketManager();
I2PSocketOptions opts = sockMgr.buildOptions(defaultOpts);
if (!defaultOpts.containsKey(I2PSocketOptions.PROP_CONNECT_TIMEOUT)) {
opts.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT);
}
return opts;
}
use of net.i2p.client.streaming.I2PSocketOptions in project i2p.i2p by i2p.
the class SAMv2StreamSession method connect.
/**
* Connect the SAM STREAM session to the specified Destination
*
* @param id Unique id for the connection
* @param dest Base64-encoded Destination to connect to
* @param props Options to be used for connection
*
* @throws DataFormatException if the destination is not valid
* @throws SAMInvalidDirectionException if trying to connect through a
* receive-only session
* @return true if the communication with the SAM client is ok
*/
@Override
public boolean connect(int id, String dest, Properties props) throws DataFormatException, SAMInvalidDirectionException {
if (!canCreate) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Trying to create an outgoing connection using a receive-only session");
throw new SAMInvalidDirectionException("Trying to create connections through a receive-only session");
}
if (checkSocketHandlerId(id)) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("The specified id (" + id + ") is already in use");
return false;
}
Destination d = SAMUtils.getDest(dest);
I2PSocketOptions opts = socketMgr.buildOptions(props);
if (props.getProperty(I2PSocketOptions.PROP_CONNECT_TIMEOUT) == null)
opts.setConnectTimeout(60 * 1000);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Connecting new I2PSocket...");
// non-blocking connection (SAMv2)
StreamConnector connector = new StreamConnector(id, d, opts);
I2PAppThread connectThread = new I2PAppThread(connector, "StreamConnector" + id);
connectThread.start();
return true;
}
Aggregations