java.lang.Object
net.i2p.router.JobImpl
net.i2p.router.client.MessageReceivedJob
- All Implemented Interfaces:
Job
Async job to notify the client that a new message is available for them, or just send it directly if specified.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LogLogger for this class.private final PayloadThe message being delivered.private final ClientConnectionRunnerThe runner delivering the message.private final booleanTrue if the message arrived directly, not through a tunnel.private final DestinationThe destination the message is addressed to.Constructor Summary
ConstructorsConstructorDescriptionMessageReceivedJob(RouterContext ctx, ClientConnectionRunner runner, Destination toDest, Destination fromDest, Payload payload, boolean sendDirect) Create a job that delivers one received message to a client.Method Summary
Modifier and TypeMethodDescriptiongetName()Descriptive name of the task.private voidmessageAvailable(MessageId id, long size) Deliver notification to the client that the given message is available.booleanSame asrunJob()but with a return value.voidrunJob()Actually perform the task.private voidsendMessage(long id) Deliver the message directly, skip notification.Methods inherited from class JobImpl
dropped, getContext, getJobId, getMadeReadyOn, getTiming, madeReady, requeue, toStringModifier and TypeMethodDescriptionvoiddropped()Default implementation does nothing.final RouterContextThe router context that this job belongs to.longgetJobId()The unique job ID for this job.longThe timestamp when this job was last made ready for execution.The timing object for this job.voidmadeReady(long now) For JobQueue only, not for external use.protected voidrequeue(long delayMs) Requeue this job to run after the specified delay.toString()
Field Details
_log
Logger for this class._runner
The runner delivering the message._toDest
The destination the message is addressed to._payload
The message being delivered._sendDirect
private final boolean _sendDirectTrue if the message arrived directly, not through a tunnel.
Constructor Details
MessageReceivedJob
public MessageReceivedJob(RouterContext ctx, ClientConnectionRunner runner, Destination toDest, Destination fromDest, Payload payload, boolean sendDirect) Create a job that delivers one received message to a client.- Parameters:
ctx- the router contextrunner- the client connection runnertoDest- non-null, required to pick sessionfromDest- sending destination, generally nullpayload- the message payloadsendDirect- if true send directly
Method Details
getName
runJob
public void runJob()Description copied from interface:JobActually perform the task. This call blocks until the Job is complete.receiveMessage
public boolean receiveMessage()Same asrunJob()but with a return value.- Returns:
- true if the payload was handed over, false if the runner is dead or the send threw
messageAvailable
Deliver notification to the client that the given message is available.- Parameters:
id- the id of the message that became availablesize- the message size in bytes- Throws:
I2CPMessageException- if the status message cannot be sent to the client
sendMessage
Deliver the message directly, skip notification.- Parameters:
id- the id of the queued message to deliver- Throws:
I2CPMessageException- if the payload message cannot be sent to the client