net.i2p.sam
Class SAMv2Handler

java.lang.Object
  extended by net.i2p.sam.SAMHandler
      extended by net.i2p.sam.SAMv1Handler
          extended by net.i2p.sam.SAMv2Handler
All Implemented Interfaces:
java.lang.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(java.nio.channels.SocketChannel s, int verMajor, int verMinor)
          Create a new SAM version 2 handler.
SAMv2Handler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, java.util.Properties i2cpProps)
          Create a new SAM version 2 handler.
 
Method Summary
protected  boolean execStreamMessage(java.lang.String opcode, java.util.Properties props)
           
(package private)  SAMStreamSession newSAMStreamSession(java.lang.String destKeystream, java.lang.String direction, java.util.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(java.nio.channels.SocketChannel s,
                    int verMajor,
                    int verMinor)
             throws SAMException,
                    java.io.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
java.io.IOException

SAMv2Handler

public SAMv2Handler(java.nio.channels.SocketChannel s,
                    int verMajor,
                    int verMinor,
                    java.util.Properties i2cpProps)
             throws SAMException,
                    java.io.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
java.io.IOException
Method Detail

verifVersion

public boolean verifVersion()
Overrides:
verifVersion in class SAMv1Handler

newSAMStreamSession

SAMStreamSession newSAMStreamSession(java.lang.String destKeystream,
                                     java.lang.String direction,
                                     java.util.Properties props)
                               throws java.io.IOException,
                                      DataFormatException,
                                      SAMException
Overrides:
newSAMStreamSession in class SAMv1Handler
Throws:
java.io.IOException
DataFormatException
SAMException

execStreamMessage

protected boolean execStreamMessage(java.lang.String opcode,
                                    java.util.Properties props)
Overrides:
execStreamMessage in class SAMv1Handler