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

public class SAMv3StreamSession
extends SAMStreamSession
implements SAMv3Handler.Session

SAMv3 STREAM session class.

Author:
mkvore

Nested Class Summary
 class SAMv3StreamSession.Pipe
           
 class SAMv3StreamSession.SocketForwarder
           
 
Nested classes/interfaces inherited from class net.i2p.sam.SAMStreamSession
SAMStreamSession.DisconnectListener, SAMStreamSession.SAMStreamSessionServer, SAMStreamSession.SAMStreamSessionSocketReader, SAMStreamSession.SAMv1StreamSessionSocketReader, SAMStreamSession.StreamSender, SAMStreamSession.v1StreamSender
 
Field Summary
protected  int BUFFER_SIZE
           
protected  java.lang.String nick
           
protected  I2PServerSocket socketServer
           
protected  java.lang.Object socketServerLock
           
 
Fields inherited from class net.i2p.sam.SAMStreamSession
canCreate, DEFAULT_FORCE_FLUSH, forceFlush, PROP_FORCE_FLUSH, recv, server, SOCKET_HANDLER_BUF_SIZE, socketMgr
 
Constructor Summary
SAMv3StreamSession(java.lang.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 an incoming STREAM
 void close()
          Close the stream session
 void connect(SAMv3Handler handler, java.lang.String dest, java.util.Properties props)
          Connect the SAM STREAM session to the specified Destination
static SAMv3Handler.SessionsDB getDB()
           
 java.lang.String getNick()
           
 I2PServerSocket getSocketServer()
           
 boolean sendBytes(java.lang.String s, byte[] b)
           
 void startForwardingIncoming(java.util.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
 

Field Detail

BUFFER_SIZE

protected final int BUFFER_SIZE
See Also:
Constant Field Values

socketServerLock

protected java.lang.Object socketServerLock

socketServer

protected I2PServerSocket socketServer

nick

protected java.lang.String nick
Constructor Detail

SAMv3StreamSession

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

Parameters:
login - The nickname
Throws:
java.io.IOException
DataFormatException
SAMException
Method Detail

getNick

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

getDB

public static SAMv3Handler.SessionsDB getDB()

connect

public void connect(SAMv3Handler handler,
                    java.lang.String dest,
                    java.util.Properties props)
             throws I2PException,
                    java.net.ConnectException,
                    java.net.NoRouteToHostException,
                    DataFormatException,
                    java.io.InterruptedIOException,
                    java.io.IOException
Connect the SAM STREAM session to the specified Destination

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
java.net.ConnectException - if the destination refuses connections
java.net.NoRouteToHostException - if the destination can't be reached
java.io.InterruptedIOException - if the connection timeouts
I2PException - if there's another I2P-related error
java.io.IOException

accept

public void accept(SAMv3Handler handler,
                   boolean verbose)
            throws I2PException,
                   java.io.InterruptedIOException,
                   java.io.IOException,
                   SAMException
Accept an incoming STREAM

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
java.net.ConnectException - if the destination refuses connections
java.net.NoRouteToHostException - if the destination can't be reached
java.io.InterruptedIOException - if the connection timeouts
I2PException - if there's another I2P-related error
java.io.IOException
SAMException

startForwardingIncoming

public void startForwardingIncoming(java.util.Properties props)
                             throws SAMException,
                                    java.io.InterruptedIOException
Throws:
SAMException
java.io.InterruptedIOException

getSocketServer

public I2PServerSocket getSocketServer()

stopForwardingIncoming

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

Throws:
SAMException
java.io.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(java.lang.String s,
                         byte[] b)
                  throws DataFormatException
Specified by:
sendBytes in interface SAMv3Handler.Session
Throws:
DataFormatException