net.i2p.sam
Class SAMv3StreamSession

java.lang.Object
  extended by net.i2p.sam.SAMStreamSession
      extended by net.i2p.sam.SAMv3StreamSession
All Implemented Interfaces:
SAMv3Handler.Session

 class SAMv3StreamSession
extends SAMStreamSession
implements SAMv3Handler.Session

SAMv3 STREAM session class.

Author:
mkvore

Nested Class Summary
 
Nested classes/interfaces inherited from class net.i2p.sam.SAMStreamSession
SAMStreamSession.DisconnectListener, SAMStreamSession.SAMStreamSessionServer, SAMStreamSession.SAMStreamSessionSocketReader, SAMStreamSession.SAMv1StreamSessionSocketReader, SAMStreamSession.StreamSender
 
Field Summary
 
Fields inherited from class net.i2p.sam.SAMStreamSession
_log, canCreate, DEFAULT_FORCE_FLUSH, forceFlush, PROP_FORCE_FLUSH, recv, server, SOCKET_HANDLER_BUF_SIZE, socketMgr
 
Constructor Summary
SAMv3StreamSession(String login)
          Create a new SAM STREAM session, according to information registered with the given nickname
 
Method Summary
 void accept(SAMv3Handler handler, boolean verbose)
          Accept a single incoming STREAM on the socket stolen from the handler.
 void close()
          Close the stream session
 void connect(SAMv3Handler handler, String dest, Properties props)
          Connect the SAM STREAM session to the specified Destination for a single connection, using the socket stolen from the handler.
static SAMv3Handler.SessionsDB getDB()
           
 String getNick()
           
 I2PServerSocket getSocketServer()
           
 boolean sendBytes(String s, byte[] b)
           
 void startForwardingIncoming(Properties props)
           
 void stopForwardingIncoming()
          stop Forwarding Incoming connection coming from I2P
 
Methods inherited from class net.i2p.sam.SAMStreamSession
checkSocketHandlerId, closeConnection, connect, createSocketHandler, getDestination, getSocketReader, newSAMStreamSessionSocketReader, newStreamSender, removeSocketHandler, sendBytes, setReceiveLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SAMv3StreamSession

public SAMv3StreamSession(String login)
                   throws IOException,
                          DataFormatException,
                          SAMException
Create a new SAM STREAM session, according to information registered with the given nickname

Parameters:
login - The nickname
Throws:
IOException
DataFormatException
SAMException
NPE - if login nickname is not registered
Method Detail

getNick

public String getNick()
Specified by:
getNick in interface SAMv3Handler.Session

getDB

public static SAMv3Handler.SessionsDB getDB()

connect

public void connect(SAMv3Handler handler,
                    String dest,
                    Properties props)
             throws I2PException,
                    ConnectException,
                    NoRouteToHostException,
                    DataFormatException,
                    InterruptedIOException,
                    IOException
Connect the SAM STREAM session to the specified Destination for a single connection, using the socket stolen from the handler.

Parameters:
handler - The handler that communicates with the requesting client
dest - Base64-encoded Destination to connect to
props - Options to be used for connection
Throws:
DataFormatException - if the destination is not valid
ConnectException - if the destination refuses connections
NoRouteToHostException - if the destination can't be reached
InterruptedIOException - if the connection timeouts
I2PException - if there's another I2P-related error
IOException

accept

public void accept(SAMv3Handler handler,
                   boolean verbose)
            throws I2PException,
                   InterruptedIOException,
                   IOException,
                   SAMException
Accept a single incoming STREAM on the socket stolen from the handler.

Parameters:
handler - The handler that communicates with the requesting client
verbose - If true, SAM will send the Base64-encoded peer Destination of an incoming socket as the first line of data sent to its client on the handler socket
Throws:
DataFormatException - if the destination is not valid
ConnectException - if the destination refuses connections
NoRouteToHostException - if the destination can't be reached
InterruptedIOException - if the connection timeouts
I2PException - if there's another I2P-related error
IOException
SAMException

startForwardingIncoming

public void startForwardingIncoming(Properties props)
                             throws SAMException,
                                    InterruptedIOException
Throws:
SAMException
InterruptedIOException

getSocketServer

public I2PServerSocket getSocketServer()

stopForwardingIncoming

public void stopForwardingIncoming()
                            throws SAMException,
                                   InterruptedIOException
stop Forwarding Incoming connection coming from I2P

Throws:
SAMException
InterruptedIOException

close

public void close()
Close the stream session

Specified by:
close in interface SAMv3Handler.Session
Overrides:
close in class SAMStreamSession

sendBytes

public boolean sendBytes(String s,
                         byte[] b)
                  throws DataFormatException
Specified by:
sendBytes in interface SAMv3Handler.Session
Throws:
DataFormatException