Package net.i2p.client.impl
Class I2PSessionMuxedImpl
java.lang.Object
net.i2p.client.impl.I2PSessionImpl
net.i2p.client.impl.I2PSessionImpl2
net.i2p.client.impl.I2PSessionMuxedImpl
- All Implemented Interfaces:
 I2PSession,I2CPMessageReader.I2CPMessageEventListener
- Direct Known Subclasses:
 SubSession
I2PSession with protocol and ports
 Streaming lib has been modified to send I2PSession.PROTO_STREAMING but
 still receives all. It sends with fromPort and toPort = 0, and receives on all ports.
 No datagram apps have been modified yet.
 Therefore the compatibility situation is as follows:
 Compatibility:
    old streaming -> new streaming: sends proto anything, rcvs proto anything
    new streaming -> old streaming: sends PROTO_STREAMING, ignores rcvd proto
    old datagram -> new datagram: sends proto anything, rcvs proto anything
    new datagram -> old datagram: sends PROTO_DATAGRAM, ignores rcvd proto
    In all the above cases, streaming and datagram receive traffic for the other
    protocol, same as before.
    old datagram -> new muxed: doesn't work because the old sends proto 0 but the udp side
                               of the mux registers with PROTO_DATAGRAM, so the datagrams
                               go to the streaming side, same as before.
    old streaming -> new muxed: works
 Typical Usage:
    Streaming + datagrams:
        I2PSocketManager sockMgr = getSocketManager();
        I2PSession session = sockMgr.getSession();
        session.addMuxedSessionListener(myI2PSessionMuxedListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
         * or *
        session.addSessionListener(myI2PSessionListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
        session.sendMessage(dest, payload, I2PSession.PROTO_DATAGRAM, fromPort, toPort);
    Datagrams only, with multiple ports:
        I2PClient client = I2PClientFactory.createClient();
        ...
        I2PSession session = client.createSession(...);
        session.addMuxedSessionListener(myI2PSessionMuxedListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
         * or *
        session.addSessionListener(myI2PSessionListener, I2PSession.PROTO_DATAGRAM, I2PSession.PORT_ANY);
        session.sendMessage(dest, payload, I2PSession.PROTO_DATAGRAM, fromPort, toPort);
    Multiple streaming ports:
        Needs some streaming lib hacking
- Since:
 - 0.7.1
 - Author:
 - zzz
 
- 
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.i2p.client.impl.I2PSessionImpl
I2PSessionImpl.AvailabilityNotifier, I2PSessionImpl.State - 
Field Summary
Fields inherited from class net.i2p.client.impl.I2PSessionImpl2
_noEffort, _sendingStates, _sendMessageNonceFields inherited from class net.i2p.client.impl.I2PSessionImpl
_availabilityNotifier, _availableMessages, _bwLimits, _bwReceivedLock, _context, _handlerMap, _hostname, _leaseSet, _leaseSetWait, _log, _pendingLookups, _portNum, _producer, _queue, _reader, _sessionListener, _socket, _state, _stateLock, _transientSigningPublicKey, _writer, CACHE_MAX_SIZE, DUMMY_SESSION, LISTEN_PORT, PROP_DOMAIN_SOCKETFields inherited from interface net.i2p.client.I2PSession
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_DATAGRAM2, PROTO_DATAGRAM3, PROTO_STREAMING, PROTO_UNSPECIFIED - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedI2PSessionMuxedImpl(I2PSessionImpl primary, InputStream destKeyStream, Properties options) I2PSessionMuxedImpl(I2PAppContext ctx, InputStream destKeyStream, Properties options)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidaddMuxedSessionListener(I2PSessionMuxedListener l, int proto, int port) Listen on specified protocol and port, and receive notification of proto, fromPort, and toPort for every message.voidReceive a payload message and let the app know its availablevoidaddSessionListener(I2PSessionListener lsnr, int proto, int port) Listen on specified protocol and port.voidremoveListener(int proto, int port) removes the specified listener (only)booleansendMessage(Destination dest, byte[] payload) unused, see MuxedImpl overridebooleansendMessage(Destination dest, byte[] payload, int proto, int fromport, int toport) See I2PSessionMuxedImpl for proto/port details.booleansendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromPort, int toPort, SendMessageOptions options) See SendMessageOptions for option details.longsendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromPort, int toPort, SendMessageOptions options, SendMessageStatusListener listener) Send a message and request an asynchronous notification of delivery status.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromport, int toport) See I2PSessionMuxedImpl for proto/port details.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) Unused? see MuxedImpl overridebooleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort) See I2PSessionMuxedImpl for proto/port details.booleansendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort, int flags) See I2PSessionMuxedImpl for proto/port details.voidlisten on all protocols and portsMethods inherited from class net.i2p.client.impl.I2PSessionImpl2
destroySession, getTimeout, receiveMessage, receiveStatus, reconnect, sendBestEffort, sendBestEffort, sendMessage, sendMessage, sendMessage, sendNoEffort, shouldCompress, startVerifyUsageMethods inherited from class net.i2p.client.impl.I2PSessionImpl
addSubsession, bandwidthLimits, bwReceived, changeState, clearCache, connect, dateUpdated, destLookupFailed, destLookupFailed, destReceived, destReceived, destroySession, disconnect, disconnected, getContext, getDecryptionKey, getFastReceive, getHandlerMap, getLastLS2SignTime, getLeaseSet, getMyDestination, getName, getOfflineExpiration, getOfflineSignature, getOptions, getPrefix, getPrivateKey, getProducer, getRouterVersion, getSessionId, getSubsessions, getTransientSigningPublicKey, isClosed, isOffline, lastActivity, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest, lookupDest2, messageReceived, propogateError, readError, removeSubsession, reportAbuse, sendBlindingInfo, sendMessage, sendMessage_unchecked, setLastLS2SignTime, setLeaseSet, setReduced, setSessionId, shouldReconnect, supportsLS2, toString, updateActivity, updateOptions, verifyOpen, waitForDate 
- 
Constructor Details
- 
I2PSessionMuxedImpl
public I2PSessionMuxedImpl(I2PAppContext ctx, InputStream destKeyStream, Properties options) throws I2PSessionException - Throws:
 I2PSessionException
 - 
I2PSessionMuxedImpl
protected I2PSessionMuxedImpl(I2PSessionImpl primary, InputStream destKeyStream, Properties options) throws I2PSessionException - Throws:
 I2PSessionException
 
 - 
 - 
Method Details
- 
setSessionListener
listen on all protocols and ports- Specified by:
 setSessionListenerin interfaceI2PSession- Overrides:
 setSessionListenerin classI2PSessionImpl- Parameters:
 lsnr- listener to retrieve events
 - 
addSessionListener
Listen on specified protocol and port. An existing listener with the same proto and port is replaced. Only the listener with the best match is called back for each message.- Specified by:
 addSessionListenerin interfaceI2PSession- Overrides:
 addSessionListenerin classI2PSessionImpl2- Parameters:
 proto- 1-254 or PROTO_ANY (0) for all; recommended: I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedport- 1-65535 or PORT_ANY (0) for all
 - 
addMuxedSessionListener
Listen on specified protocol and port, and receive notification of proto, fromPort, and toPort for every message.- Specified by:
 addMuxedSessionListenerin interfaceI2PSession- Overrides:
 addMuxedSessionListenerin classI2PSessionImpl2- Parameters:
 proto- 1-254 or PROTO_ANY (0) for all; 255 disallowedport- 1-65535 or PORT_ANY (0) for all
 - 
removeListener
public void removeListener(int proto, int port) removes the specified listener (only)- Specified by:
 removeListenerin interfaceI2PSession- Overrides:
 removeListenerin classI2PSessionImpl2
 - 
sendMessage
Description copied from class:I2PSessionImpl2unused, see MuxedImpl override- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 dest- location to send the messagepayload- body of the message to be sent (unencrypted)- Returns:
 - whether it was accepted by the router for delivery or not
 - Throws:
 I2PSessionException
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int proto, int fromport, int toport) throws I2PSessionException Description copied from interface:I2PSessionSee I2PSessionMuxedImpl for proto/port details.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Returns:
 - success
 - Throws:
 I2PSessionException
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires) throws I2PSessionException Description copied from class:I2PSessionImpl2Unused? see MuxedImpl override- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 keyUsed- unused - no end-to-end cryptotagsSent- unused - no end-to-end cryptoexpires- absolute expiration timestamp, NOT interval from now- Returns:
 - success
 - Throws:
 I2PSessionException
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, int proto, int fromport, int toport) throws I2PSessionException Description copied from interface:I2PSessionSee I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 keyUsed- unused - no end-to-end cryptotagsSent- unused - no end-to-end cryptoproto- 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedfromport- 1-65535 or 0 for unsettoport- 1-65535 or 0 for unset- Returns:
 - success
 - Throws:
 I2PSessionException
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort) throws I2PSessionException Description copied from interface:I2PSessionSee I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 keyUsed- unused - no end-to-end cryptotagsSent- unused - no end-to-end cryptoexpires- absolute expiration timestamp, NOT interval from nowproto- 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedfromPort- 1-65535 or 0 for unsettoPort- 1-65535 or 0 for unset- Returns:
 - success
 - Throws:
 I2PSessionException- Since:
 - 0.7.1
 
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, SessionKey keyUsed, Set<SessionTag> tagsSent, long expires, int proto, int fromPort, int toPort, int flags) throws I2PSessionException Description copied from interface:I2PSessionSee I2PSessionMuxedImpl for proto/port details. End-to-End Crypto is disabled, tags and keys are ignored.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 keyUsed- unused - no end-to-end cryptotagsSent- unused - no end-to-end cryptoexpires- absolute expiration timestamp, NOT interval from nowproto- 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedfromPort- 1-65535 or 0 for unsettoPort- 1-65535 or 0 for unsetflags- to be passed to the router- Returns:
 - success
 - Throws:
 I2PSessionException- Since:
 - 0.8.4
 
 - 
sendMessage
public boolean sendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromPort, int toPort, SendMessageOptions options) throws I2PSessionException See SendMessageOptions for option details. Always uses sendNoEffort for now.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 proto- 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedfromPort- 1-65535 or 0 for unsettoPort- 1-65535 or 0 for unsetoptions- to be passed to the router- Returns:
 - success
 - Throws:
 I2PSessionException- Since:
 - 0.9.2
 
 - 
sendMessage
public long sendMessage(Destination dest, byte[] payload, int offset, int size, int proto, int fromPort, int toPort, SendMessageOptions options, SendMessageStatusListener listener) throws I2PSessionException Send a message and request an asynchronous notification of delivery status. See I2PSessionMuxedImpl for proto/port details. See SendMessageOptions for option details.- Specified by:
 sendMessagein interfaceI2PSession- Overrides:
 sendMessagein classI2PSessionImpl2- Parameters:
 proto- 1-254 or 0 for unset; recommended: I2PSession.PROTO_UNSPECIFIED I2PSession.PROTO_STREAMING I2PSession.PROTO_DATAGRAM 255 disallowedfromPort- 1-65535 or 0 for unsettoPort- 1-65535 or 0 for unsetoptions- to be passed to the router- Returns:
 - the message ID to be used for later notification to the listener
 - Throws:
 I2PSessionException- on all errors- Since:
 - 0.9.14
 
 - 
addNewMessage
Receive a payload message and let the app know its available- Overrides:
 addNewMessagein classI2PSessionImpl
 
 -