|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.client.I2PSessionImpl
abstract class I2PSessionImpl
Implementation of an I2P session running over TCP. This class is NOT thread safe - only one thread should send messages at any given time
Nested Class Summary | |
---|---|
protected class |
I2PSessionImpl.AvailabilityNotifier
This notifies the client of payload messages. |
Field Summary | |
---|---|
protected I2PSessionImpl.AvailabilityNotifier |
_availabilityNotifier
thread that we tell when new messages are available who then tells us to fetch them. |
protected Map<Long,MessagePayloadMessage> |
_availableMessages
map of Long --> MessagePayloadMessage |
protected int[] |
_bwLimits
|
protected Object |
_bwReceivedLock
|
protected boolean |
_closed
whether the session connection has already been closed (or not yet opened) |
protected boolean |
_closing
whether the session connection is in the process of being closed |
protected I2PAppContext |
_context
used to seperate things out so we can get rid of singletons |
protected I2PClientMessageHandlerMap |
_handlerMap
|
protected String |
_hostname
hostname of router - will be null if in RouterContext |
protected Log |
_log
|
protected boolean |
_opening
whether the session connection is in the process of being opened |
protected OutputStream |
_out
where we pipe our messages |
protected LinkedBlockingQueue<net.i2p.client.I2PSessionImpl.LookupWaiter> |
_pendingLookups
hashes of lookups we are waiting for |
protected int |
_portNum
port num to router - will be 0 if in RouterContext |
protected I2CPMessageProducer |
_producer
class that generates new messages |
protected I2CPMessageQueue |
_queue
Used for internal connections to the router. |
protected I2CPMessageReader |
_reader
reader that always searches for messages |
protected I2PSessionListener |
_sessionListener
who we send events to |
protected Socket |
_socket
socket for comm |
protected ClientWriterRunner |
_writer
writer message queue |
static int |
LISTEN_PORT
|
protected static String |
PROP_ENABLE_SSL
SSL interface (only) @since 0.8.3 |
Fields inherited from interface net.i2p.client.I2PSession |
---|
PORT_ANY, PORT_UNSPECIFIED, PROTO_ANY, PROTO_DATAGRAM, PROTO_DATAGRAM_RAW, PROTO_STREAMING, PROTO_UNSPECIFIED |
Constructor Summary | |
---|---|
|
I2PSessionImpl(I2PAppContext context,
InputStream destKeyStream,
Properties options)
Create a new session, reading the Destination, PrivateKey, and SigningPrivateKey from the destKeyStream, and using the specified options to connect to the router |
protected |
I2PSessionImpl(I2PAppContext context,
Properties options)
for extension |
Method Summary | |
---|---|
void |
addNewMessage(MessagePayloadMessage msg)
Recieve a payload message and let the app know its available |
int[] |
bandwidthLimits()
Blocking. |
(package private) void |
bwReceived(int[] i)
called by the message handler |
void |
connect()
Connect to the router and establish a session. |
(package private) void |
dateUpdated()
|
(package private) void |
destLookupFailed(Hash h)
called by the message handler |
(package private) void |
destReceived(Destination d)
called by the message handler |
void |
destroySession()
Tear down the session, and do NOT reconnect. |
void |
destroySession(boolean sendDisconnect)
Tear down the session, and do NOT reconnect. |
protected void |
disconnect()
|
void |
disconnected(I2CPMessageReader reader)
The I2CPMessageEventListener callback. |
PrivateKey |
getDecryptionKey()
Retrieve the decryption PrivateKey |
boolean |
getFastReceive()
|
(package private) LeaseSet |
getLeaseSet()
|
Destination |
getMyDestination()
Retrieve the destination of the session |
(package private) boolean |
getOpening()
|
(package private) Properties |
getOptions()
Retrieve the configuration options |
protected String |
getPrefix()
try hard to make a decent identifier as this will appear in error logs |
SigningPrivateKey |
getPrivateKey()
Retrieve the signing SigningPrivateKey |
(package private) I2CPMessageProducer |
getProducer()
Retrieve the helper that generates I2CP messages |
(package private) SessionId |
getSessionId()
Retrieve the session's ID |
boolean |
isClosed()
has the session been closed (or not yet connected)? |
long |
lastActivity()
|
Destination |
lookupDest(Hash h)
Blocking. |
Destination |
lookupDest(Hash h,
long maxWait)
Blocking. |
void |
messageReceived(I2CPMessageReader reader,
I2CPMessage message)
The I2CPMessageEventListener callback. |
(package private) void |
propogateError(String msg,
Throwable error)
Pass off the error to the listener Misspelled, oh well. |
void |
readError(I2CPMessageReader reader,
Exception error)
The I2CPMessageEventListener callback. |
byte[] |
receiveMessage(int msgId)
Pull the unencrypted data from the message that we've already prefetched and notified the user that its available. |
abstract void |
receiveStatus(int msgId,
long nonce,
int status)
|
protected boolean |
reconnect()
|
void |
reportAbuse(int msgId,
int severity)
Report abuse with regards to the given messageId |
(package private) void |
sendMessage(I2CPMessage message)
Deliver an I2CP message to the router As of 0.9.3, may block for several seconds if the write queue to the router is full |
(package private) void |
setLeaseSet(LeaseSet ls)
|
(package private) void |
setOpening(boolean ls)
|
void |
setReduced()
|
(package private) void |
setSessionId(SessionId id)
|
void |
setSessionListener(I2PSessionListener lsnr)
configure the listener |
protected boolean |
shouldReconnect()
|
String |
toString()
|
protected void |
updateActivity()
|
void |
updateOptions(Properties options)
Update the tunnel and bandwidth settings |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.i2p.client.I2PSession |
---|
addMuxedSessionListener, addSessionListener, removeListener, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage |
Field Detail |
---|
protected final Log _log
protected String _hostname
protected int _portNum
protected Socket _socket
protected I2CPMessageReader _reader
protected ClientWriterRunner _writer
protected OutputStream _out
protected I2CPMessageQueue _queue
protected I2PSessionListener _sessionListener
protected I2CPMessageProducer _producer
protected Map<Long,MessagePayloadMessage> _availableMessages
protected final LinkedBlockingQueue<net.i2p.client.I2PSessionImpl.LookupWaiter> _pendingLookups
protected final Object _bwReceivedLock
protected int[] _bwLimits
protected I2PClientMessageHandlerMap _handlerMap
protected final I2PAppContext _context
protected volatile boolean _closed
protected volatile boolean _closing
protected volatile boolean _opening
protected I2PSessionImpl.AvailabilityNotifier _availabilityNotifier
protected static final String PROP_ENABLE_SSL
public static final int LISTEN_PORT
Constructor Detail |
---|
protected I2PSessionImpl(I2PAppContext context, Properties options)
public I2PSessionImpl(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException
destKeyStream
- stream containing the private key data,
format is specified in PrivateKeyFile
options
- set of options to configure the router with, if null will use System properties
I2PSessionException
- if there is a problem loading the private keys orMethod Detail |
---|
void dateUpdated()
public void updateOptions(Properties options)
updateOptions
in interface I2PSession
options
- non-nullpublic boolean getFastReceive()
void setLeaseSet(LeaseSet ls)
LeaseSet getLeaseSet()
void setOpening(boolean ls)
boolean getOpening()
public void connect() throws I2PSessionException
connect
in interface I2PSession
I2PSessionException
- if there is a configuration error or the router is
not reachablepublic byte[] receiveMessage(int msgId) throws I2PSessionException
receiveMessage
in interface I2PSession
msgId
- message to fetch
I2PSessionException
public void reportAbuse(int msgId, int severity) throws I2PSessionException
reportAbuse
in interface I2PSession
msgId
- message that was abusive (or -1 for not message related)severity
- how abusive
I2PSessionException
public abstract void receiveStatus(int msgId, long nonce, int status)
public void addNewMessage(MessagePayloadMessage msg)
public void messageReceived(I2CPMessageReader reader, I2CPMessage message)
messageReceived
in interface I2CPMessageReader.I2CPMessageEventListener
reader
- unusedmessage
- the I2CPMessagepublic void readError(I2CPMessageReader reader, Exception error)
readError
in interface I2CPMessageReader.I2CPMessageEventListener
reader
- unusederror
- non-nullpublic Destination getMyDestination()
getMyDestination
in interface I2PSession
public PrivateKey getDecryptionKey()
getDecryptionKey
in interface I2PSession
public SigningPrivateKey getPrivateKey()
getPrivateKey
in interface I2PSession
I2CPMessageProducer getProducer()
Properties getOptions()
SessionId getSessionId()
void setSessionId(SessionId id)
public void setSessionListener(I2PSessionListener lsnr)
setSessionListener
in interface I2PSession
lsnr
- listener to retrieve eventspublic boolean isClosed()
isClosed
in interface I2PSession
void sendMessage(I2CPMessage message) throws I2PSessionException
I2PSessionException
- if the message is malformed or there is an error writing it outvoid propogateError(String msg, Throwable error)
error
- non-nullpublic void destroySession()
destroySession
in interface I2PSession
public void destroySession(boolean sendDisconnect)
public void disconnected(I2CPMessageReader reader)
disconnected
in interface I2CPMessageReader.I2CPMessageEventListener
reader
- unusedprotected void disconnect()
protected boolean shouldReconnect()
protected boolean reconnect()
protected String getPrefix()
void destReceived(Destination d)
void destLookupFailed(Hash h)
void bwReceived(int[] i)
public Destination lookupDest(Hash h) throws I2PSessionException
lookupDest
in interface I2PSession
I2PSessionException
public Destination lookupDest(Hash h, long maxWait) throws I2PSessionException
lookupDest
in interface I2PSession
maxWait
- ms
I2PSessionException
public int[] bandwidthLimits() throws I2PSessionException
bandwidthLimits
in interface I2PSession
I2PSessionException
protected void updateActivity()
public long lastActivity()
public void setReduced()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |