Runnable, Handler, SAMDatagramReceiver, SAMRawReceiver, SAMStreamReceiverSAMv2Handler, SAMv3Handlerclass SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramReceiver, SAMStreamReceiver
| Modifier and Type | Field | Description |
|---|---|---|
protected long |
_id |
|
protected SAMMessageSess |
datagramSession |
|
protected SAMMessageSess |
rawSession |
|
protected static String |
SESSION_ERROR |
|
protected SAMStreamSession |
streamSession |
_log, bridge, i2cpProps, socket, stopHandler, stopLock, thread, verMajor, verMinor| Constructor | Description |
|---|---|
SAMv1Handler(SocketChannel s,
int verMajor,
int verMinor,
Properties i2cpProps,
SAMBridge parent) |
Create a new SAM version 1 handler.
|
SAMv1Handler(SocketChannel s,
int verMajor,
int verMinor,
SAMBridge parent) |
Create a new SAM version 1 handler.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected static String |
createMessageString(String msg) |
Create a string to be appended to a status.
|
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 SAMMessageSess |
getDatagramSession() |
|
protected SAMMessageSess |
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,
int proto,
int fromPort,
int toPort) |
Send a byte array to a SAM client.
|
void |
receiveRawBytes(byte[] data,
int proto,
int fromPort,
int toPort) |
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() |
|
protected boolean |
writeString(String s,
String msg) |
Write a string and message, escaping the message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcloseClientSocket, getClientSocket, getWriteLock, run, shouldStop, startHandling, stopHandling, toString, writeBytes, writeString, writeStringprotected SAMMessageSess rawSession
protected SAMMessageSess datagramSession
protected SAMStreamSession streamSession
protected final long _id
protected static final String SESSION_ERROR
public SAMv1Handler(SocketChannel s, int verMajor, int verMinor, SAMBridge parent) throws SAMException, IOException
s - Socket attached to a SAM clientverMajor - SAM major version to manage (should be 1)verMinor - SAM minor version to manageSAMExceptionIOExceptionpublic SAMv1Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps, SAMBridge parent) 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)SAMExceptionIOExceptionprotected final SAMMessageSess getRawSession()
protected final SAMMessageSess getDatagramSession()
protected final SAMStreamSession getStreamSession()
public boolean verifVersion()
public void handle()
SAMHandlerhandle in class SAMHandlerprotected 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,
int proto,
int fromPort,
int toPort)
throws IOException
SAMRawReceiverreceiveRawBytes in interface SAMRawReceiverdata - Byte array to be receivedproto - I2CP protocolfromPort - I2CP from porttoPort - I2CP to portIOExceptionpublic void stopRawReceiving()
SAMRawReceiverstopRawReceiving in interface SAMRawReceiverpublic void receiveDatagramBytes(Destination sender, byte[] data, int proto, int fromPort, int toPort) throws IOException
SAMDatagramReceiverreceiveDatagramBytes in interface SAMDatagramReceiversender - Destinationdata - Byte array to be receivedproto - I2CP protocolfromPort - I2CP from porttoPort - I2CP to portIOExceptionpublic void stopDatagramReceiving()
SAMDatagramReceiverstopDatagramReceiving in interface SAMDatagramReceiverpublic void streamSendAnswer(int id,
String result,
String bufferState)
throws IOException
SAMStreamReceiverstreamSendAnswer in interface SAMStreamReceiverid - Stream IDresult - informationbufferState - state of the bufferIOExceptionpublic void notifyStreamSendBufferFree(int id)
throws IOException
SAMStreamReceivernotifyStreamSendBufferFree in interface SAMStreamReceiverid - stream IDIOExceptionpublic void notifyStreamIncomingConnection(int id,
Destination d)
throws IOException
SAMStreamReceivernotifyStreamIncomingConnection in interface SAMStreamReceiverid - New connection idd - DestinationIOExceptionpublic void notifyStreamOutgoingConnection(int id,
String result,
String msg)
throws IOException
SAMStreamReceivernotifyStreamOutgoingConnection in interface SAMStreamReceivermsg - may be nullid - New connection idresult - message resultIOExceptionprotected static String createMessageString(String msg)
msg - may be nullprotected boolean writeString(String s, String msg)
s - The string, non-nullpublic void receiveStreamBytes(int id,
ByteBuffer data)
throws IOException
SAMStreamReceiverreceiveStreamBytes in interface SAMStreamReceiverid - Connection iddata - Byte array to be receivedIOExceptionpublic void notifyStreamDisconnection(int id,
String result,
String msg)
throws IOException
SAMStreamReceivernotifyStreamDisconnection in interface SAMStreamReceivermsg - may be nullid - Connection idresult - Disconnection reason ("OK" or something else)IOExceptionpublic void stopStreamReceiving()
SAMStreamReceiverstopStreamReceiving in interface SAMStreamReceiver