Search in sources :

Example 1 with BandwidthLimitsMessage

use of net.i2p.data.i2cp.BandwidthLimitsMessage 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 BandwidthLimitsMessage

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

the class BWLimitsMessageHandler method handleMessage.

public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("Handle message " + message);
    BandwidthLimitsMessage msg = (BandwidthLimitsMessage) message;
    session.bwReceived(msg.getLimits());
}
Also used : BandwidthLimitsMessage(net.i2p.data.i2cp.BandwidthLimitsMessage)

Example 3 with BandwidthLimitsMessage

use of net.i2p.data.i2cp.BandwidthLimitsMessage 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)3 GetBandwidthLimitsMessage (net.i2p.data.i2cp.GetBandwidthLimitsMessage)2 I2CPMessageException (net.i2p.data.i2cp.I2CPMessageException)2