Search in sources :

Example 1 with ReceiveMessageBeginMessage

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

the class MessageStatusMessageHandler method handleMessage.

public void handleMessage(I2CPMessage message, I2PSessionImpl session) {
    if (_log.shouldLog(Log.DEBUG))
        _log.debug("Handle message " + message);
    MessageStatusMessage msg = (MessageStatusMessage) message;
    int status = msg.getStatus();
    long id = msg.getMessageId();
    switch(status) {
        case MessageStatusMessage.STATUS_AVAILABLE:
            ReceiveMessageBeginMessage m = new ReceiveMessageBeginMessage();
            m.setMessageId(id);
            m.setSessionId(msg.getSessionId());
            try {
                session.sendMessage(m);
            } catch (I2PSessionException ise) {
                _log.error("Error asking for the message", ise);
            }
            return;
        case MessageStatusMessage.STATUS_SEND_ACCEPTED:
            session.receiveStatus((int) id, msg.getNonce(), status);
            // noop
            return;
        default:
            if (msg.isSuccessful()) {
                if (_log.shouldLog(Log.DEBUG))
                    _log.debug("Message delivery succeeded for message " + id);
            } else {
                if (_log.shouldLog(Log.INFO))
                    _log.info("Message delivery FAILED (" + status + ") for message " + id);
            }
            // if (!skipStatus)
            session.receiveStatus((int) id, msg.getNonce(), status);
            return;
    }
}
Also used : I2PSessionException(net.i2p.client.I2PSessionException) MessageStatusMessage(net.i2p.data.i2cp.MessageStatusMessage) ReceiveMessageBeginMessage(net.i2p.data.i2cp.ReceiveMessageBeginMessage)

Aggregations

I2PSessionException (net.i2p.client.I2PSessionException)1 MessageStatusMessage (net.i2p.data.i2cp.MessageStatusMessage)1 ReceiveMessageBeginMessage (net.i2p.data.i2cp.ReceiveMessageBeginMessage)1