net.i2p.sam

## Class SAMv3StreamSession

- java.lang.Object
- - net.i2p.sam.SAMStreamSession
  - - 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

Nested Classes
`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

Fields
`protected int` `BUFFER_SIZE`
`protected String` `nick`
`protected I2PServerSocket` `socketServer`
`protected 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

Constructors
Constructor and Description
`SAMv3StreamSession(String login)` Create a new SAM STREAM session, according to information registered with the given nickname

### Method Summary

Methods
`void` `accept(SAMv3Handler handler, boolean verbose)` Accept an incoming STREAM
`void` `close()` Close the stream session
`void` `connect(SAMv3Handler handler, String dest, Properties props)` Connect the SAM STREAM session to the specified Destination
`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`

### Field Detail

#### BUFFER_SIZE

    protected final int BUFFER_SIZE

See Also:
  Constant Field Values

#### socketServerLock

    protected Object socketServerLock

#### socketServer

    protected I2PServerSocket socketServer

#### nick

    protected String nick

### 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`

### 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

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 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
  `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`