Search in sources :

Example 1 with SetDateMessage

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

the class SetDateMessageHandler method handleMessage.

public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("Handle message " + message);
    SetDateMessage msg = (SetDateMessage) message;
    // we did was get the time from ourselves.
    if (!_context.isRouterContext())
        Clock.getInstance().setNow(msg.getDate().getTime());
    // TODO - save router's version string for future reference
    session.dateUpdated(msg.getVersion());
}
Also used : SetDateMessage(net.i2p.data.i2cp.SetDateMessage)

Example 2 with SetDateMessage

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

the class ClientMessageEventListener method handleGetDate.

/**
 *  Defaults in GetDateMessage options are NOT honored.
 *  Defaults are not serialized out-of-JVM, and the router does not recognize defaults in-JVM.
 *  Client side must promote defaults to the primary map.
 */
private void handleGetDate(GetDateMessage message) {
    // sent by clients >= 0.8.7
    String clientVersion = message.getVersion();
    if (clientVersion != null)
        _runner.setClientVersion(clientVersion);
    Properties props = message.getOptions();
    if (!checkAuth(props))
        return;
    try {
        // only send version if the client can handle it (0.8.7 or greater)
        _runner.doSend(new SetDateMessage(clientVersion != null ? CoreVersion.VERSION : null));
    } catch (I2CPMessageException ime) {
        if (_log.shouldLog(Log.ERROR))
            _log.error("Error writing out the setDate message", ime);
    }
}
Also used : I2CPMessageException(net.i2p.data.i2cp.I2CPMessageException) Properties(java.util.Properties) SetDateMessage(net.i2p.data.i2cp.SetDateMessage)

Aggregations

SetDateMessage (net.i2p.data.i2cp.SetDateMessage)2 Properties (java.util.Properties)1 I2CPMessageException (net.i2p.data.i2cp.I2CPMessageException)1