java.lang.Object
net.i2p.sam.SAMMessageSession.SAMMessageSessionHandler
- All Implemented Interfaces:
Runnable, I2PSessionListener, I2PSessionMuxedListener
- Enclosing class:
SAMMessageSession
private class SAMMessageSession.SAMMessageSessionHandlerextends Object implements Runnable, I2PSessionMuxedListener
SAM message-based session handler, running in its own thread.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final I2PSessionThe session whose messages are received.private final ObjectThe lock held while the receiver runs.private booleanTrue while the receiver runs.Constructor Summary
ConstructorsConstructorDescriptionSAMMessageSessionHandler(InputStream destStream, Properties props) Create a new SAM message-based session handler.Create a new SAM message-based session handler on an existing I2PSession.Method Summary
All MethodsModifier and TypeMethodDescriptionvoiddisconnected(I2PSession session) Stops the session when the underlying I2P session drops.voiderrorOccurred(I2PSession session, String message, Throwable error) Notify the client that some error occurred.final I2PSessionThe session.voidmessageAvailable(I2PSession session, int msgId, long size) Fetches the named message with unspecified protocol and ports.voidmessageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) Forward a received message to the SAM client.voidreportAbuse(I2PSession session, int severity) Logs the abuse report and stops the session.voidrun()Serves the session's listener thread until the session stops.final voidStop a SAM message-based session handling thread.
Field Details
_session
The session whose messages are received.runningLock
The lock held while the receiver runs.stillRunning
private volatile boolean stillRunningTrue while the receiver runs.
Constructor Details
SAMMessageSessionHandler
public SAMMessageSessionHandler(InputStream destStream, Properties props) throws I2PSessionException Create a new SAM message-based session handler.- Parameters:
destStream- Input stream containing the destination keysprops- Properties to setup the I2P session- Throws:
I2PSessionException- if the session cannot be created
SAMMessageSessionHandler
Create a new SAM message-based session handler on an existing I2PSession.- Parameters:
sess- the session to receive from
Method Details
getSession
The session.- Returns:
- the I2PSession this handler was constructed around, either a newly created and connected one or an existing one passed in
stopRunning
public final void stopRunning()Stop a SAM message-based session handling thread.run
disconnected
Stops the session when the underlying I2P session drops.- Specified by:
disconnectedin interfaceI2PSessionListener- Specified by:
disconnectedin interfaceI2PSessionMuxedListener- Parameters:
session- the session that was terminated
errorOccurred
Description copied from interface:I2PSessionMuxedListenerNotify the client that some error occurred. All registered listeners will be called.- Specified by:
errorOccurredin interfaceI2PSessionListener- Specified by:
errorOccurredin interfaceI2PSessionMuxedListener- Parameters:
session- the session that reported the errormessage- a human-readable description of the errorerror- the cause, non-null
messageAvailable
Fetches the named message with unspecified protocol and ports.- Specified by:
messageAvailablein interfaceI2PSessionListener- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message payload in bytes. The I2CP payload size is an int internally and is widened to long here, so the value is never negative
messageAvailable
public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort) Forward a received message to the SAM client.- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message payload in bytes. The I2CP payload size is an int internally and is widened to long here, so the value is never negativeproto- 1-254 or 0 for unspecifiedfromPort- 1-65535 or 0 for unspecifiedtoPort- 1-65535 or 0 for unspecified
reportAbuse
Logs the abuse report and stops the session.- Specified by:
reportAbusein interfaceI2PSessionListener- Specified by:
reportAbusein interfaceI2PSessionMuxedListener- Parameters:
session- session to report abuse toseverity- how bad the abuse is