class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramReceiver, SAMStreamReceiver
Modifier and Type | Field and Description |
---|---|
protected long |
_id |
protected SAMDatagramSession |
datagramSession |
protected SAMRawSession |
rawSession |
protected SAMStreamSession |
streamSession |
Constructor and Description |
---|
SAMv1Handler(SocketChannel s,
int verMajor,
int verMinor)
Create a new SAM version 1 handler.
|
SAMv1Handler(SocketChannel s,
int verMajor,
int verMinor,
Properties i2cpProps)
Create a new SAM version 1 handler.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
execDatagramMessage(String opcode,
Properties props) |
protected boolean |
execDestMessage(String opcode,
Properties props) |
protected boolean |
execNamingMessage(String opcode,
Properties props) |
protected boolean |
execRawMessage(String opcode,
Properties props) |
protected boolean |
execSessionMessage(String opcode,
Properties props) |
protected boolean |
execStreamClose(Properties props) |
protected boolean |
execStreamConnect(Properties props) |
protected boolean |
execStreamMessage(String opcode,
Properties props) |
protected boolean |
execStreamSend(Properties props) |
protected SAMDatagramSession |
getDatagramSession() |
protected SAMRawSession |
getRawSession() |
protected SAMStreamSession |
getStreamSession() |
void |
handle()
Actually handle the SAM protocol.
|
void |
notifyStreamDisconnection(int id,
String result,
String msg)
Notify that a connection has been closed
FIXME: this interface should be cleaner
|
void |
notifyStreamIncomingConnection(int id,
Destination d)
Notify about a new incoming connection
|
void |
notifyStreamOutgoingConnection(int id,
String result,
String msg)
Notify about a new outgoing connection
|
void |
notifyStreamSendBufferFree(int id)
Notifies that the outwards buffer is free for writing
|
void |
receiveDatagramBytes(Destination sender,
byte[] data)
Send a byte array to a SAM client.
|
void |
receiveRawBytes(byte[] data)
Send a byte array to a SAM client, without informations
regarding the sender.
|
void |
receiveStreamBytes(int id,
ByteBuffer data)
Transmit a byte array from I2P to a SAM client.
|
void |
stopDatagramReceiving()
Stop receiving data.
|
void |
stopRawReceiving()
Stop receiving data.
|
void |
stopStreamReceiving()
Stop receiving data.
|
void |
streamSendAnswer(int id,
String result,
String bufferState)
Sends the result of a stream send operation
|
boolean |
verifVersion() |
closeClientSocket, getClientSocket, getWriteLock, run, setBridge, shouldStop, startHandling, stopHandling, toString, writeBytes, writeBytes, writeString, writeString
protected SAMRawSession rawSession
protected SAMDatagramSession datagramSession
protected SAMStreamSession streamSession
protected final long _id
public SAMv1Handler(SocketChannel s, int verMajor, int verMinor) throws SAMException, IOException
s
- Socket attached to a SAM clientverMajor
- SAM major version to manage (should be 1)verMinor
- SAM minor version to manageSAMException
IOException
public SAMv1Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps) throws SAMException, IOException
s
- Socket attached to a SAM clientverMajor
- SAM major version to manage (should be 1)verMinor
- SAM minor version to managei2cpProps
- properties to configure the I2CP connection (host, port, etc)SAMException
IOException
protected SAMRawSession getRawSession()
protected SAMDatagramSession getDatagramSession()
protected SAMStreamSession getStreamSession()
public boolean verifVersion()
public void handle()
SAMHandler
handle
in class SAMHandler
protected boolean execSessionMessage(String opcode, Properties props)
protected boolean execDestMessage(String opcode, Properties props)
protected boolean execNamingMessage(String opcode, Properties props)
protected boolean execDatagramMessage(String opcode, Properties props)
protected boolean execRawMessage(String opcode, Properties props)
protected boolean execStreamMessage(String opcode, Properties props)
protected boolean execStreamSend(Properties props)
protected boolean execStreamConnect(Properties props)
protected boolean execStreamClose(Properties props)
public void receiveRawBytes(byte[] data) throws IOException
SAMRawReceiver
receiveRawBytes
in interface SAMRawReceiver
data
- Byte array to be receivedIOException
public void stopRawReceiving()
SAMRawReceiver
stopRawReceiving
in interface SAMRawReceiver
public void receiveDatagramBytes(Destination sender, byte[] data) throws IOException
SAMDatagramReceiver
receiveDatagramBytes
in interface SAMDatagramReceiver
sender
- Destinationdata
- Byte array to be receivedIOException
public void stopDatagramReceiving()
SAMDatagramReceiver
stopDatagramReceiving
in interface SAMDatagramReceiver
public void streamSendAnswer(int id, String result, String bufferState) throws IOException
SAMStreamReceiver
streamSendAnswer
in interface SAMStreamReceiver
id
- Stream IDresult
- informationbufferState
- state of the bufferIOException
public void notifyStreamSendBufferFree(int id) throws IOException
SAMStreamReceiver
notifyStreamSendBufferFree
in interface SAMStreamReceiver
id
- stream IDIOException
public void notifyStreamIncomingConnection(int id, Destination d) throws IOException
SAMStreamReceiver
notifyStreamIncomingConnection
in interface SAMStreamReceiver
id
- New connection idd
- DestinationIOException
public void notifyStreamOutgoingConnection(int id, String result, String msg) throws IOException
SAMStreamReceiver
notifyStreamOutgoingConnection
in interface SAMStreamReceiver
id
- New connection idresult
- message resultmsg
- MessageIOException
public void receiveStreamBytes(int id, ByteBuffer data) throws IOException
SAMStreamReceiver
receiveStreamBytes
in interface SAMStreamReceiver
id
- Connection iddata
- Byte array to be receivedIOException
public void notifyStreamDisconnection(int id, String result, String msg) throws IOException
SAMStreamReceiver
notifyStreamDisconnection
in interface SAMStreamReceiver
id
- Connection idresult
- Disconnection reason ("OK" or something else)msg
- Error message, if anyIOException
public void stopStreamReceiving()
SAMStreamReceiver
stopStreamReceiving
in interface SAMStreamReceiver