@Override protected byte[] doWriteMessage() throws I2CPMessageException, IOException { if ((_sessionId == null) || (_severity == null) || (_reason == null)) throw new I2CPMessageException("Not enough information to construct the message"); ByteArrayOutputStream os = new ByteArrayOutputStream(32); try { _sessionId.writeBytes(os); _severity.writeBytes(os); _reason.writeBytes(os); if (_messageId == null) { _messageId = new MessageId(); _messageId.setMessageId(0); } _messageId.writeBytes(os); } catch (DataFormatException dfe) { throw new I2CPMessageException("Error writing out the message data", dfe); } return os.toByteArray(); }
@Override public boolean equals(Object object) { if ((object == null) || !(object instanceof MessageId)) return false; return _messageId == ((MessageId) object).getMessageId(); }
public DataStructure createDataStructure() throws DataFormatException { MessageId id = new MessageId(); id.setMessageId(101); return id; } public DataStructure createStructureToRead() { return new MessageId(); }
Payload payload = message.getPayload(); Destination dest = message.getDestination(); MessageId id = new MessageId(); id.setMessageId(getNextMessageId()); long expiration = 0; int flags = 0; _log.debug("** Receiving message " + id.getMessageId() + " with payload of size " + payload.getSize() + " for session " + message.getSessionId());
public DataStructure createStructureToRead() { return new MessageId(); } }
@Override protected void doReadMessage(InputStream in, int size) throws I2CPMessageException, IOException { try { _sessionId = new SessionId(); _sessionId.readBytes(in); _severity = new AbuseSeverity(); _severity.readBytes(in); _reason = new AbuseReason(); _reason.readBytes(in); _messageId = new MessageId(); _messageId.readBytes(in); } catch (DataFormatException dfe) { throw new I2CPMessageException("Unable to load the message data", dfe); } }
if (s.getMessageId() != null && s.getMessageId().getMessageId() == msgId) { if (_log.shouldLog(Log.DEBUG)) _log.debug(getPrefix() + "Found a matching state by msgId"); state = s; MessageId id = new MessageId(); id.setMessageId(msgId); state.setMessageId(id);
/** * Send an abuse message to the router */ public void reportAbuse(I2PSessionImpl session, int msgId, int severity) throws I2PSessionException { ReportAbuseMessage msg = new ReportAbuseMessage(); MessageId id = new MessageId(); id.setMessageId(msgId); msg.setMessageId(id); AbuseReason reason = new AbuseReason(); reason.setReason("Not specified"); msg.setReason(reason); AbuseSeverity sv = new AbuseSeverity(); sv.setSeverity(severity); msg.setSeverity(sv); session.sendMessage(msg); }
/** * The client told us that the message has been received completely. This currently * does not do any security checking prior to removing the message from the * pending queue, though it should. * */ private void handleReceiveEnd(ReceiveMessageEndMessage message) { _runner.removePayload(new MessageId(message.getMessageId())); }
/** * Send a notification to the client that their message (id specified) was accepted * for delivery (but not necessarily delivered) * Doesn't do anything if i2cp.messageReliability = "none" * or if the nonce is 0. * * @param id OUR id for the message * @param nonce HIS id for the message */ void ackSendMessage(SessionId sid, MessageId id, long nonce) { if (_dontSendMSM || nonce == 0) return; if (_log.shouldLog(Log.DEBUG)) _log.debug("Acking message send [accepted]" + id + " / " + nonce + " for sessionId " + sid); MessageStatusMessage status = new MessageStatusMessage(); status.setMessageId(id.getMessageId()); status.setSessionId(sid.getSessionId()); status.setSize(0L); status.setNonce(nonce); status.setStatus(MessageStatusMessage.STATUS_SEND_ACCEPTED); try { doSend(status); _acceptedPending.remove(id); } catch (I2CPMessageException ime) { if (_log.shouldLog(Log.WARN)) _log.warn("Error writing out the message status message", ime); } }
sendMessage(nextID); } else { id = new MessageId(nextID); _runner.setPayload(id, _payload); messageAvailable(id, _payload.getSize());
/** * Deliver notification to the client that the given message is available. */ private void messageAvailable(MessageId id, long size) throws I2CPMessageException { //if (_log.shouldLog(Log.DEBUG)) // _log.debug("Sending message available: " + id + " to sessionId " + _runner.getSessionId() // + " (with nonce=1)", new Exception("available")); MessageStatusMessage msg = new MessageStatusMessage(); msg.setMessageId(id.getMessageId()); SessionId sid = _runner.getSessionId(_toDest.calculateHash()); if (sid == null) { if (_log.shouldLog(Log.WARN)) _log.warn("No session for " + _toDest.calculateHash()); return; } msg.setSessionId(sid.getSessionId()); msg.setSize(size); // has to be >= 0, it is initialized to -1 msg.setNonce(1); msg.setStatus(MessageStatusMessage.STATUS_AVAILABLE); _runner.doSend(msg); }
msg.setMessageId(_messageId.getMessageId()); msg.setSessionId(_sessId.getSessionId());
/** * No job queue, so super NPEs */ @Override void updateMessageDeliveryStatus(Destination dest, MessageId id, long messageNonce, int status) { if (messageNonce <= 0) return; MessageStatusMessage msg = new MessageStatusMessage(); msg.setMessageId(id.getMessageId()); msg.setSessionId(getSessionId(dest.calculateHash()).getSessionId()); // has to be >= 0, it is initialized to -1 msg.setNonce(messageNonce); msg.setSize(0); msg.setStatus(status); try { doSend(msg); } catch (I2CPMessageException ime) { _log.warn("Error updating the status for " + id, ime); } }
getContext().messageHistory().sendPayloadMessage(_clientMessageId.getMessageId(), false, sendTime); getContext().clientManager().messageDeliveryStatusUpdate(_from, _clientMessageId, _clientMessage.getMessageNonce(), status);