Handler
, SAMDatagramReceiver
, SAMRawReceiver
, SAMStreamReceiver
SAMv2Handler
, SAMv3Handler
class SAMv1Handler extends SAMHandler implements SAMRawReceiver, SAMDatagramReceiver, SAMStreamReceiver
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected long |
_id |
|
protected SAMMessageSess |
datagramSession |
|
protected SAMMessageSess |
rawSession |
|
protected static java.lang.String |
SESSION_ERROR |
|
protected SAMStreamSession |
streamSession |
_log, bridge, i2cpProps, socket, stopHandler, stopLock, thread, verMajor, verMinor
コンストラクタ | 説明 |
---|---|
SAMv1Handler(java.nio.channels.SocketChannel s,
int verMajor,
int verMinor,
java.util.Properties i2cpProps,
SAMBridge parent) |
Create a new SAM version 1 handler.
|
SAMv1Handler(java.nio.channels.SocketChannel s,
int verMajor,
int verMinor,
SAMBridge parent) |
Create a new SAM version 1 handler.
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
protected static java.lang.String |
createMessageString(java.lang.String msg) |
Create a string to be appended to a status.
|
protected boolean |
execDatagramMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execDestMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execNamingMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execRawMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execSessionMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execStreamClose(java.util.Properties props) |
|
protected boolean |
execStreamConnect(java.util.Properties props) |
|
protected boolean |
execStreamMessage(java.lang.String opcode,
java.util.Properties props) |
|
protected boolean |
execStreamSend(java.util.Properties props) |
|
protected SAMMessageSess |
getDatagramSession() |
|
protected SAMMessageSess |
getRawSession() |
|
protected SAMStreamSession |
getStreamSession() |
|
void |
handle() |
Actually handle the SAM protocol.
|
void |
notifyStreamDisconnection(int id,
java.lang.String result,
java.lang.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,
java.lang.String result,
java.lang.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,
java.nio.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,
java.lang.String result,
java.lang.String bufferState) |
Sends the result of a stream send operation
|
boolean |
verifVersion() |
|
protected boolean |
writeString(java.lang.String s,
java.lang.String msg) |
Write a string and message, escaping the message.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
closeClientSocket, getClientSocket, getWriteLock, run, shouldStop, startHandling, stopHandling, toString, writeBytes, writeString, writeString
protected SAMMessageSess rawSession
protected SAMMessageSess datagramSession
protected SAMStreamSession streamSession
protected final long _id
protected static final java.lang.String SESSION_ERROR
public SAMv1Handler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, SAMBridge parent) throws SAMException, java.io.IOException
s
- Socket attached to a SAM clientverMajor
- SAM major version to manage (should be 1)verMinor
- SAM minor version to manageSAMException
java.io.IOException
public SAMv1Handler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, java.util.Properties i2cpProps, SAMBridge parent) throws SAMException, java.io.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
java.io.IOException
protected final SAMMessageSess getRawSession()
protected final SAMMessageSess getDatagramSession()
protected final SAMStreamSession getStreamSession()
public boolean verifVersion()
public void handle()
SAMHandler
handle
クラス内 SAMHandler
protected boolean execSessionMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execDestMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execNamingMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execDatagramMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execRawMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execStreamMessage(java.lang.String opcode, java.util.Properties props)
protected boolean execStreamSend(java.util.Properties props)
protected boolean execStreamConnect(java.util.Properties props)
protected boolean execStreamClose(java.util.Properties props)
public void receiveRawBytes(byte[] data, int proto, int fromPort, int toPort) throws java.io.IOException
SAMRawReceiver
receiveRawBytes
インタフェース内 SAMRawReceiver
data
- Byte array to be receivedproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portjava.io.IOException
public void stopRawReceiving()
SAMRawReceiver
stopRawReceiving
インタフェース内 SAMRawReceiver
public void receiveDatagramBytes(Destination sender, byte[] data, int proto, int fromPort, int toPort) throws java.io.IOException
SAMDatagramReceiver
receiveDatagramBytes
インタフェース内 SAMDatagramReceiver
sender
- Destinationdata
- Byte array to be receivedproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portjava.io.IOException
public void stopDatagramReceiving()
SAMDatagramReceiver
stopDatagramReceiving
インタフェース内 SAMDatagramReceiver
public void streamSendAnswer(int id, java.lang.String result, java.lang.String bufferState) throws java.io.IOException
SAMStreamReceiver
streamSendAnswer
インタフェース内 SAMStreamReceiver
id
- Stream IDresult
- informationbufferState
- state of the bufferjava.io.IOException
public void notifyStreamSendBufferFree(int id) throws java.io.IOException
SAMStreamReceiver
notifyStreamSendBufferFree
インタフェース内 SAMStreamReceiver
id
- stream IDjava.io.IOException
public void notifyStreamIncomingConnection(int id, Destination d) throws java.io.IOException
SAMStreamReceiver
notifyStreamIncomingConnection
インタフェース内 SAMStreamReceiver
id
- New connection idd
- Destinationjava.io.IOException
public void notifyStreamOutgoingConnection(int id, java.lang.String result, java.lang.String msg) throws java.io.IOException
SAMStreamReceiver
notifyStreamOutgoingConnection
インタフェース内 SAMStreamReceiver
msg
- may be nullid
- New connection idresult
- message resultjava.io.IOException
protected static java.lang.String createMessageString(java.lang.String msg)
msg
- may be nullprotected boolean writeString(java.lang.String s, java.lang.String msg)
s
- The string, non-nullpublic void receiveStreamBytes(int id, java.nio.ByteBuffer data) throws java.io.IOException
SAMStreamReceiver
receiveStreamBytes
インタフェース内 SAMStreamReceiver
id
- Connection iddata
- Byte array to be receivedjava.io.IOException
public void notifyStreamDisconnection(int id, java.lang.String result, java.lang.String msg) throws java.io.IOException
SAMStreamReceiver
notifyStreamDisconnection
インタフェース内 SAMStreamReceiver
msg
- may be nullid
- Connection idresult
- Disconnection reason ("OK" or something else)java.io.IOException
public void stopStreamReceiving()
SAMStreamReceiver
stopStreamReceiving
インタフェース内 SAMStreamReceiver