net.i2p.router.client
Class ClientConnectionRunner

java.lang.Object
  extended by net.i2p.router.client.ClientConnectionRunner

public class ClientConnectionRunner
extends java.lang.Object

Bridge the router and the client - managing state for a client.

Author:
jrandom

Constructor Summary
ClientConnectionRunner(RouterContext context, ClientManager manager, java.net.Socket socket)
          Create a new runner against the given socket
 
Method Summary
(package private)  void ackSendMessage(MessageId id, long nonce)
          Send a notification to the client that their message (id specified) was accepted for delivery (but not necessarily delivered)
(package private)  void disconnectClient(java.lang.String reason)
           
(package private)  void disconnected()
           
(package private)  MessageId distributeMessage(SendMessageMessage message)
          Distribute the message.
(package private)  void doSend(I2CPMessage msg)
          Actually send the I2CPMessage to the peer through the socket
 SessionConfig getConfig()
          current client's config
 Hash getDestHash()
           
(package private)  boolean getIsDead()
           
(package private)  LeaseRequestState getLeaseRequest()
          data for the current leaseRequest, or null if there is no active leaseSet request
 LeaseSet getLeaseSet()
          currently allocated leaseSet
(package private) static int getNextMessageId()
           
(package private)  Payload getPayload(MessageId id)
          message body
(package private)  SessionId getSessionId()
          current client's sessionId
 SessionKeyManager getSessionKeyManager()
          current client's sessionkeymanager
(package private)  boolean isDead()
          already closed?
(package private)  void leaseSetCreated(LeaseSet ls)
          called after a new leaseSet is granted by the client, the NetworkDb has been updated.
(package private)  void receiveMessage(Destination toDest, Destination fromDest, Payload payload)
          Asynchronously deliver the message to the current runner
(package private)  void removePayload(MessageId id)
           
 void reportAbuse(java.lang.String reason, int severity)
          Send async abuse message to the client
(package private)  void requestLeaseSet(LeaseSet set, long expirationTime, Job onCreateJob, Job onFailedJob)
          Request that a particular client authorize the Leases contained in the LeaseSet, after which the onCreateJob is queued up.
(package private)  void sessionEstablished(SessionConfig config)
           
(package private)  void setLeaseRequest(LeaseRequestState req)
           
(package private)  void setLeaseSet(LeaseSet ls)
           
(package private)  void setPayload(MessageId id, Payload payload)
           
(package private)  void setSessionId(SessionId id)
           
 void startRunning()
          Actually run the connection - listen for I2CP messages and respond.
(package private)  void stopRunning()
          die a horrible death
(package private)  void updateMessageDeliveryStatus(MessageId id, boolean delivered)
           
(package private)  void writeMessage(I2CPMessage msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientConnectionRunner

public ClientConnectionRunner(RouterContext context,
                              ClientManager manager,
                              java.net.Socket socket)
Create a new runner against the given socket

Method Detail

startRunning

public void startRunning()
Actually run the connection - listen for I2CP messages and respond. This is the main driver for this class, though it gets all its meat from the I2CPMessageReader


stopRunning

void stopRunning()
die a horrible death


getConfig

public SessionConfig getConfig()
current client's config


getSessionKeyManager

public SessionKeyManager getSessionKeyManager()
current client's sessionkeymanager


getLeaseSet

public LeaseSet getLeaseSet()
currently allocated leaseSet


setLeaseSet

void setLeaseSet(LeaseSet ls)

getDestHash

public Hash getDestHash()

getSessionId

SessionId getSessionId()
current client's sessionId


setSessionId

void setSessionId(SessionId id)

getLeaseRequest

LeaseRequestState getLeaseRequest()
data for the current leaseRequest, or null if there is no active leaseSet request


setLeaseRequest

void setLeaseRequest(LeaseRequestState req)

isDead

boolean isDead()
already closed?


getPayload

Payload getPayload(MessageId id)
message body


setPayload

void setPayload(MessageId id,
                Payload payload)

removePayload

void removePayload(MessageId id)

sessionEstablished

void sessionEstablished(SessionConfig config)

updateMessageDeliveryStatus

void updateMessageDeliveryStatus(MessageId id,
                                 boolean delivered)

leaseSetCreated

void leaseSetCreated(LeaseSet ls)
called after a new leaseSet is granted by the client, the NetworkDb has been updated. This takes care of all the LeaseRequestState stuff (including firing any jobs)


disconnectClient

void disconnectClient(java.lang.String reason)

distributeMessage

MessageId distributeMessage(SendMessageMessage message)
Distribute the message. If the dest is local, it blocks until its passed to the target ClientConnectionRunner (which then fires it into a MessageReceivedJob). If the dest is remote, it blocks until it is added into the ClientMessagePool


ackSendMessage

void ackSendMessage(MessageId id,
                    long nonce)
Send a notification to the client that their message (id specified) was accepted for delivery (but not necessarily delivered)


receiveMessage

void receiveMessage(Destination toDest,
                    Destination fromDest,
                    Payload payload)
Asynchronously deliver the message to the current runner


reportAbuse

public void reportAbuse(java.lang.String reason,
                        int severity)
Send async abuse message to the client


requestLeaseSet

void requestLeaseSet(LeaseSet set,
                     long expirationTime,
                     Job onCreateJob,
                     Job onFailedJob)
Request that a particular client authorize the Leases contained in the LeaseSet, after which the onCreateJob is queued up. If that doesn't occur within the timeout specified, queue up the onFailedJob. This call does not block.

Parameters:
set - LeaseSet with requested leases - this object must be updated to contain the signed version (as well as any changed/added/removed Leases)
expirationTime - ms to wait before failing
onCreateJob - Job to run after the LeaseSet is authorized
onFailedJob - Job to run after the timeout passes without receiving authorization

disconnected

void disconnected()

getIsDead

boolean getIsDead()

writeMessage

void writeMessage(I2CPMessage msg)

doSend

void doSend(I2CPMessage msg)
      throws I2CPMessageException
Actually send the I2CPMessage to the peer through the socket

Throws:
I2CPMessageException

getNextMessageId

static int getNextMessageId()