|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.sam.SAMHandler
public abstract class SAMHandler
Base class for SAM protocol handlers. It implements common methods, but is not able to actually parse the protocol itself: this task is delegated to subclasses.
Field Summary | |
---|---|
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 I2PAppThread |
thread
|
protected int |
verMajor
|
protected int |
verMinor
|
Constructor Summary | |
---|---|
protected |
SAMHandler(java.nio.channels.SocketChannel s,
int verMajor,
int verMinor,
java.util.Properties i2cpProps)
SAMHandler constructor (to be called by subclasses) |
Method Summary | |
---|---|
protected void |
closeClientSocket()
Close the socket connected to the SAM client. |
protected java.nio.channels.SocketChannel |
getClientSocket()
Get the input stream 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()
|
void |
setBridge(SAMBridge 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 |
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. |
static void |
writeBytes(java.nio.ByteBuffer data,
java.nio.channels.SocketChannel out)
|
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)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected I2PAppThread thread
protected SAMBridge bridge
protected java.nio.channels.SocketChannel socket
protected int verMajor
protected int verMinor
protected java.util.Properties i2cpProps
Constructor Detail |
---|
protected SAMHandler(java.nio.channels.SocketChannel s, int verMajor, int verMinor, java.util.Properties i2cpProps) 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
Method Detail |
---|
public final void startHandling()
public void setBridge(SAMBridge bridge)
protected abstract void handle()
protected final java.nio.channels.SocketChannel getClientSocket()
java.io.IOException
protected final void writeBytes(java.nio.ByteBuffer data) throws java.io.IOException
data
- A byte array to be written
java.io.IOException
public static void writeBytes(java.nio.ByteBuffer data, java.nio.channels.SocketChannel out) throws java.io.IOException
java.io.IOException
protected java.lang.Object getWriteLock()
protected final boolean writeString(java.lang.String str)
str
- A byte array to be written
public static boolean writeString(java.lang.String str, java.nio.channels.SocketChannel out)
protected final void closeClientSocket() throws java.io.IOException
java.io.IOException
public final void stopHandling()
protected final boolean shouldStop()
public final java.lang.String toString()
toString
in class java.lang.Object
public final void run()
run
in interface java.lang.Runnable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |