Search in sources :

Example 1 with GetBandwidthLimitsMessage

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

the class LocalClientMessageEventListener method handleGetBWLimits.

/**
 *  Send dummy limits
 */
@Override
protected void handleGetBWLimits(GetBandwidthLimitsMessage message) {
    int limit = 1024 * 1024;
    BandwidthLimitsMessage msg = new BandwidthLimitsMessage(limit, limit);
    try {
        _runner.doSend(msg);
    } catch (I2CPMessageException ime) {
        ime.printStackTrace();
    }
}
Also used : I2CPMessageException(net.i2p.data.i2cp.I2CPMessageException) BandwidthLimitsMessage(net.i2p.data.i2cp.BandwidthLimitsMessage) GetBandwidthLimitsMessage(net.i2p.data.i2cp.GetBandwidthLimitsMessage)

Example 2 with GetBandwidthLimitsMessage

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

the class ClientMessageEventListener method handleGetBWLimits.

/**
 * Divide router limit by 1.75 for overhead.
 * This could someday give a different answer to each client.
 * But it's not enforced anywhere.
 */
protected void handleGetBWLimits(GetBandwidthLimitsMessage message) {
    if (_log.shouldLog(Log.INFO))
        _log.info("Got BW Limits request");
    int in = _context.bandwidthLimiter().getInboundKBytesPerSecond() * 4 / 7;
    int out = _context.bandwidthLimiter().getOutboundKBytesPerSecond() * 4 / 7;
    BandwidthLimitsMessage msg = new BandwidthLimitsMessage(in, out);
    try {
        _runner.doSend(msg);
    } catch (I2CPMessageException ime) {
        if (_log.shouldLog(Log.WARN))
            _log.warn("Error writing bw limits msg", ime);
    }
}
Also used : I2CPMessageException(net.i2p.data.i2cp.I2CPMessageException) BandwidthLimitsMessage(net.i2p.data.i2cp.BandwidthLimitsMessage) GetBandwidthLimitsMessage(net.i2p.data.i2cp.GetBandwidthLimitsMessage)

Aggregations

BandwidthLimitsMessage (net.i2p.data.i2cp.BandwidthLimitsMessage)2 GetBandwidthLimitsMessage (net.i2p.data.i2cp.GetBandwidthLimitsMessage)2 I2CPMessageException (net.i2p.data.i2cp.I2CPMessageException)2