## net.i2p.sam
Class SAMv2Handler

    java.lang.Object
      net.i2p.sam.SAMHandler
          net.i2p.sam.SAMv1Handler
              net.i2p.sam.SAMv2Handler

All Implemented Interfaces:
  Runnable, SAMDatagramReceiver, SAMRawReceiver, SAMStreamReceiver

    public class SAMv2Handler

extends SAMv1Handler
implements SAMRawReceiver, SAMDatagramReceiver, SAMStreamReceiver

Class able to handle a SAM version 2 client connection.

Author:
  mkvore

Field Summary

Fields inherited from class net.i2p.sam.SAMv1Handler
`__id, _id, datagramSession, rawSession, streamSession, verMajorId, verMinorId`

Fields inherited from class net.i2p.sam.SAMHandler
`bridge, i2cpProps, socket, thread, verMajor, verMinor`

Constructor Summary
`SAMv2Handler(SocketChannel s, int verMajor, int verMinor)` Create a new SAM version 2 handler.
`SAMv2Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps)` Create a new SAM version 2 handler.

Method Summary
`protected boolean` `execStreamMessage(String opcode, Properties props)`
`(package private) SAMStreamSession` `newSAMStreamSession(String destKeystream, String direction, Properties props)`
`boolean` `verifVersion()`

Methods inherited from class net.i2p.sam.SAMv1Handler

`execDatagramMessage, execDestMessage, execNamingMessage, execRawMessage, execSessionMessage, execStreamClose, execStreamConnect, execStreamSend, getDatagramSession, getRawSession, getStreamSession, handle, notifyStreamDisconnection, notifyStreamIncomingConnection, notifyStreamOutgoingConnection, notifyStreamSendBufferFree, receiveDatagramBytes, receiveRawBytes, receiveStreamBytes, stopDatagramReceiving, stopRawReceiving, stopStreamReceiving, streamSendAnswer`

Methods inherited from class net.i2p.sam.SAMHandler
`closeClientSocket, getClientSocket, getWriteLock, run, setBridge, shouldStop, startHandling, stopHandling, toString, writeBytes, writeBytes, writeString, writeString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface net.i2p.sam.SAMRawReceiver
`receiveRawBytes, stopRawReceiving`

Methods inherited from interface net.i2p.sam.SAMDatagramReceiver
`receiveDatagramBytes, stopDatagramReceiving`

Methods inherited from interface net.i2p.sam.SAMStreamReceiver
`notifyStreamDisconnection, notifyStreamIncomingConnection, notifyStreamOutgoingConnection, notifyStreamSendBufferFree, receiveStreamBytes, stopStreamReceiving, streamSendAnswer`

Constructor Detail

### SAMv2Handler

    public SAMv2Handler(SocketChannel s,
                        int verMajor,
                        int verMinor)
                 throws SAMException,
                        IOException

  Create a new SAM version 2 handler. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.

  Parameters:
    `s` - Socket attached to a SAM client
    `verMajor` - SAM major version to manage (should be 2)
    `verMinor` - SAM minor version to manage
  Throws:
    `SAMException`
    `IOException`

### SAMv2Handler

    public SAMv2Handler(SocketChannel s,
                        int verMajor,
                        int verMinor,
                        Properties i2cpProps)
                 throws SAMException,
                        IOException

  Create a new SAM version 2 handler. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.

  Parameters:
    `s` - Socket attached to a SAM client
    `verMajor` - SAM major version to manage (should be 2)
    `verMinor` - SAM minor version to manage
    `i2cpProps` - properties to configure the I2CP connection (host, port, etc)
  Throws:
    `SAMException`
    `IOException`

Method Detail

### verifVersion

    public boolean verifVersion()

  Overrides:
    `verifVersion` in class `SAMv1Handler`

### newSAMStreamSession

    SAMStreamSession newSAMStreamSession(String destKeystream,
                                         String direction,
                                         Properties props)
                                   throws IOException,
                                          DataFormatException,
                                          SAMException

  Overrides:
    `newSAMStreamSession` in class `SAMv1Handler`
  Throws:
    `IOException`
    `DataFormatException`
    `SAMException`

### execStreamMessage

    protected boolean execStreamMessage(String opcode,
                                        Properties props)

  Overrides:
    `execStreamMessage` in class `SAMv1Handler`