java.lang.Object
net.i2p.client.streaming.impl.MessageHandler
- All Implemented Interfaces:
I2PSessionListener, I2PSessionMuxedListener
Receive raw information from the I2PSession and turn it into Packets, if we can.
I2PSession -> MessageHandler -> PacketHandler -> ConnectionPacketHandler -> MessageInputStream.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final I2PAppContextThe context the handler runs in.private final Set<I2PSocketManager.DisconnectListener> Notified when a destination disconnects.private final LogLogger for this class.private final ConnectionManagerThe manager whose messages are handled.private final AtomicBooleanTrue while a session restart is queued.Constructor Summary
ConstructorsConstructorDescriptionMessageHandler(I2PAppContext ctx, ConnectionManager mgr) Creates a new MessageHandler.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidAdd a disconnect listener.voiddisconnected(I2PSession session) Notify the client that the session has been terminated.voiderrorOccurred(I2PSession session, String message, Throwable error) Notify the client that some error occurred.voidmessageAvailable(I2PSession session, int msgId, long size) Instruct the client that the given session has received a message with size # of bytes.voidmessageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) Instruct the client that the given session has received a message with size # of bytes.voidRemove a disconnect listener.voidreportAbuse(I2PSession session, int severity) Instruct the client that the session specified seems to be under attack and that the client may wish to move its destination to another router.
Field Details
_manager
The manager whose messages are handled._context
The context the handler runs in._log
Logger for this class._listeners
Notified when a destination disconnects._restartPending
True while a session restart is queued.
Constructor Details
MessageHandler
Creates a new MessageHandler.- Parameters:
ctx- the I2P app contextmgr- the connection manager
Method Details
messageAvailable
Instruct the client that the given session has received a message with size # of bytes. This shouldn't be called anymore since we are registering as a muxed listener.- Specified by:
messageAvailablein interfaceI2PSessionListener- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message
messageAvailable
public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) Instruct the client that the given session has received a message with size # of bytes.- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the messageproto- 1-254 or 0 for unspecifiedfromPort- 1-65535 or 0 for unspecifiedtoPort- 1-65535 or 0 for unspecified
reportAbuse
Instruct the client that the session specified seems to be under attack and that the client may wish to move its destination to another router.- Specified by:
reportAbusein interfaceI2PSessionListener- Specified by:
reportAbusein interfaceI2PSessionMuxedListener- Parameters:
session- session to report abuse toseverity- how bad the abuse is
disconnected
Notify the client that the session has been terminated.The listeners are not cleared here, so they are notified again after a subsequent connection and disconnection.
- Specified by:
disconnectedin interfaceI2PSessionListener- Specified by:
disconnectedin interfaceI2PSessionMuxedListener- Parameters:
session- that has been terminated
errorOccurred
Notify the client that some error occurred.- Specified by:
errorOccurredin interfaceI2PSessionListener- Specified by:
errorOccurredin interfaceI2PSessionMuxedListener- Parameters:
session- of the clientmessage- to send to the client about the errorerror- the actual error
addDisconnectListener
Add a disconnect listener.- Parameters:
lsnr- the listener to add
removeDisconnectListener
Remove a disconnect listener.- Parameters:
lsnr- the listener to remove