java.lang.Runnable
, Handler
SAMv1Handler
abstract class SAMHandler extends java.lang.Object implements java.lang.Runnable, Handler
修飾子とタイプ | フィールド | 説明 |
---|---|---|
protected Log |
_log |
|
protected SAMBridge |
bridge |
|
protected java.util.Properties |
i2cpProps |
I2CP options configuring the I2CP connection (port, host, numHops, etc)
|
protected java.nio.channels.SocketChannel |
socket |
|
protected boolean |
stopHandler |
|
protected java.lang.Object |
stopLock |
|
protected I2PAppThread |
thread |
|
int |
verMajor |
|
int |
verMinor |
修飾子 | コンストラクタ | 説明 |
---|---|---|
protected |
SAMHandler(java.nio.channels.SocketChannel s,
int verMajor,
int verMinor,
java.util.Properties i2cpProps,
SAMBridge parent) |
SAMHandler constructor (to be called by subclasses)
|
修飾子とタイプ | メソッド | 説明 |
---|---|---|
protected void |
closeClientSocket() |
Close the socket connected to the SAM client.
|
protected java.nio.channels.SocketChannel |
getClientSocket() |
Get the channel of the socket connected to the SAM client
|
protected java.lang.Object |
getWriteLock() |
If you're crazy enough to write to the raw socket, grab the write lock
with getWriteLock(), synchronize against it, and write to the getOut()
|
protected abstract void |
handle() |
Actually handle the SAM protocol.
|
void |
run() |
Register with the bridge, call handle(),
unregister with the bridge.
|
protected boolean |
shouldStop() |
Should the handler be stopped?
|
void |
startHandling() |
Start handling the SAM connection, detaching an handling thread.
|
void |
stopHandling() |
Stop the SAM handler, close the client socket,
unregister with the bridge.
|
java.lang.String |
toString() |
Get a string describing the handler.
|
protected void |
writeBytes(java.nio.ByteBuffer data) |
Write a byte array on the handler's socket.
|
protected boolean |
writeString(java.lang.String str) |
Write a string to the handler's socket.
|
static boolean |
writeString(java.lang.String str,
java.nio.channels.SocketChannel out) |
Unsynchronized, use with caution
|
protected final Log _log
protected I2PAppThread thread
protected final SAMBridge bridge
protected final java.nio.channels.SocketChannel socket
public final int verMajor
public final int verMinor
protected final java.util.Properties i2cpProps
protected final java.lang.Object stopLock
protected boolean stopHandler
protected SAMHandler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, java.util.Properties i2cpProps, SAMBridge parent) throws java.io.IOException
s
- Socket attached to a SAM clientverMajor
- SAM major version to manageverMinor
- SAM minor version to managei2cpProps
- properties to configure the I2CP connection (host, port, etc)java.io.IOException
public final void startHandling()
protected abstract void handle()
protected final java.nio.channels.SocketChannel getClientSocket()
protected final void writeBytes(java.nio.ByteBuffer data) throws java.io.IOException
data
- A byte array to be writtenjava.io.IOException
protected java.lang.Object getWriteLock()
protected final boolean writeString(java.lang.String str)
str
- A byte array to be writtenpublic static boolean writeString(java.lang.String str, java.nio.channels.SocketChannel out)
protected final void closeClientSocket() throws java.io.IOException
java.io.IOException
public void stopHandling()
stopHandling
インタフェース内 Handler
protected final boolean shouldStop()
public final java.lang.String toString()
toString
クラス内 java.lang.Object
public final void run()
run
インタフェース内 java.lang.Runnable