Package net.i2p.client.impl
Class I2PSessionDemultiplexer
- java.lang.Object
-
- net.i2p.client.impl.I2PSessionDemultiplexer
-
- All Implemented Interfaces:
I2PSessionListener,I2PSessionMuxedListener
public class I2PSessionDemultiplexer extends Object implements I2PSessionMuxedListener
Implement multiplexing with a 1-byte 'protocol' and a two-byte 'port'. Listeners register with either addListener() or addMuxedListener(), depending on whether they want to hear about the protocol, from port, and to port for every received message. messageAvailable() only calls one listener, not all that apply. The others call all listeners.- Since:
- 0.7.1
- Author:
- zzz
-
-
Constructor Summary
Constructors Constructor Description I2PSessionDemultiplexer(I2PAppContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(I2PSessionListener l, int proto, int port)For those that don't need to hear about the protocol and ports in messageAvailable() (Streaming lib)voidaddMuxedListener(I2PSessionMuxedListener l, int proto, int port)For those that do care UDP perhapsvoiddisconnected(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)unusedvoidmessageAvailable(I2PSession session, int msgId, long size, int proto, int fromport, int toport)Instruct the client that the given session has received a message Will be called only if you register via addMuxedSessionListener().voidremoveListener(int proto, int port)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.
-
-
-
Constructor Detail
-
I2PSessionDemultiplexer
public I2PSessionDemultiplexer(I2PAppContext ctx)
-
-
Method Detail
-
messageAvailable
public void messageAvailable(I2PSession session, int msgId, long size)
unused- Specified by:
messageAvailablein interfaceI2PSessionListener- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message - why it's a long and not an int is a mystery
-
messageAvailable
public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromport, int toport)
Description copied from interface:I2PSessionMuxedListenerInstruct the client that the given session has received a message Will be called only if you register via addMuxedSessionListener(). Will be called only for the proto(s) and toport(s) you register for. After this is called, the client should call receiveMessage(msgId). There is currently no method for the client to reject the message. If the client does not call receiveMessage() within a timeout period (currently 30 seconds), the session will delete the message and log an error. Only one listener is called for a given message, even if more than one have registered. See I2PSessionDemultiplexer for details.- Specified by:
messageAvailablein interfaceI2PSessionMuxedListener- Parameters:
session- session to notifymsgId- message number availablesize- size of the message - why it's a long and not an int is a mysteryproto- 1-254 or 0 for unspecifiedfromport- 1-65535 or 0 for unspecifiedtoport- 1-65535 or 0 for unspecified
-
reportAbuse
public void reportAbuse(I2PSession session, int severity)
Description copied from interface:I2PSessionMuxedListenerInstruct the client that the session specified seems to be under attack and that the client may wish to move its destination to another router. All registered listeners will be called. Unused. Not fully implemented.- Specified by:
reportAbusein interfaceI2PSessionListener- Specified by:
reportAbusein interfaceI2PSessionMuxedListener- Parameters:
session- session to report abuse toseverity- how bad the abuse is
-
disconnected
public void disconnected(I2PSession session)
Description copied from interface:I2PSessionMuxedListenerNotify the client that the session has been terminated. All registered listeners will be called.- Specified by:
disconnectedin interfaceI2PSessionListener- Specified by:
disconnectedin interfaceI2PSessionMuxedListener
-
errorOccurred
public void errorOccurred(I2PSession session, String message, Throwable error)
Description copied from interface:I2PSessionMuxedListenerNotify the client that some error occurred. All registered listeners will be called.- Specified by:
errorOccurredin interfaceI2PSessionListener- Specified by:
errorOccurredin interfaceI2PSessionMuxedListenererror- can be null? or not?
-
addListener
public void addListener(I2PSessionListener l, int proto, int port)
For those that don't need to hear about the protocol and ports in messageAvailable() (Streaming lib)
-
addMuxedListener
public void addMuxedListener(I2PSessionMuxedListener l, int proto, int port)
For those that do care UDP perhaps
-
removeListener
public void removeListener(int proto, int port)
-
-