Package net.i2p.sam.client
Class SAMEventHandler
java.lang.Object
net.i2p.sam.client.SAMClientEventListenerImpl
net.i2p.sam.client.SAMEventHandler
- All Implemented Interfaces:
SAMReader.SAMClientEventListener
public class SAMEventHandler extends SAMClientEventListenerImpl
Simple helper implementation of a the SAMClientEventListener
-
Field Summary
Fields inherited from interface net.i2p.sam.client.SAMReader.SAMClientEventListener
NAMING_REPLY_INVALID_KEY, NAMING_REPLY_KEY_NOT_FOUND, NAMING_REPLY_OK, SESSION_STATUS_DUPLICATE_DEST, SESSION_STATUS_I2P_ERROR, SESSION_STATUS_INVALID_KEY, SESSION_STATUS_OK, STREAM_CLOSED_CANT_REACH_PEER, STREAM_CLOSED_I2P_ERROR, STREAM_CLOSED_OK, STREAM_CLOSED_PEER_NOT_FOUND, STREAM_CLOSED_TIMEOUT, STREAM_STATUS_CANT_REACH_PEER, STREAM_STATUS_I2P_ERROR, STREAM_STATUS_INVALID_KEY, STREAM_STATUS_OK, STREAM_STATUS_TIMEOUT
-
Constructor Summary
Constructors Constructor Description SAMEventHandler(I2PAppContext ctx)
-
Method Summary
Modifier and Type Method Description void
helloReplyReceived(boolean ok, String version)
void
namingReplyReceived(String name, String result, String value, String msg)
void
sessionStatusReceived(String result, String destination, String msg)
may be called twice, first for CREATE and second for ADDvoid
streamStatusReceived(String result, String id, String message)
void
unknownMessageReceived(String major, String minor, Properties params)
String
waitForHelloReply()
Wait for the connection to be established, returning the server version if everything went okString
waitForNamingReply(String name)
Return the destination found matching the name, or null if the key was not able to be retrieved.boolean
waitForSessionAddReply()
Wait for the session to be added, returning true if everything went okboolean
waitForSessionCreateReply()
Wait for the session to be created, returning true if everything went okboolean
waitForStreamStatusReply()
Wait for the stream to be created, returning true if everything went okMethods inherited from class net.i2p.sam.client.SAMClientEventListenerImpl
datagramReceived, destReplyReceived, pingReceived, pongReceived, rawReceived, streamClosedReceived, streamConnectedReceived, streamDataReceived
-
Constructor Details
-
Method Details
-
helloReplyReceived
- Specified by:
helloReplyReceived
in interfaceSAMReader.SAMClientEventListener
- Overrides:
helloReplyReceived
in classSAMClientEventListenerImpl
-
sessionStatusReceived
may be called twice, first for CREATE and second for ADD- Specified by:
sessionStatusReceived
in interfaceSAMReader.SAMClientEventListener
- Overrides:
sessionStatusReceived
in classSAMClientEventListenerImpl
-
namingReplyReceived
- Specified by:
namingReplyReceived
in interfaceSAMReader.SAMClientEventListener
- Overrides:
namingReplyReceived
in classSAMClientEventListenerImpl
-
streamStatusReceived
- Specified by:
streamStatusReceived
in interfaceSAMReader.SAMClientEventListener
- Overrides:
streamStatusReceived
in classSAMClientEventListenerImpl
-
unknownMessageReceived
- Specified by:
unknownMessageReceived
in interfaceSAMReader.SAMClientEventListener
- Overrides:
unknownMessageReceived
in classSAMClientEventListenerImpl
-
waitForHelloReply
Wait for the connection to be established, returning the server version if everything went ok- Returns:
- SAM server version if everything ok, or null on failure
-
waitForSessionCreateReply
public boolean waitForSessionCreateReply()Wait for the session to be created, returning true if everything went ok- Returns:
- true if everything ok
-
waitForSessionAddReply
public boolean waitForSessionAddReply()Wait for the session to be added, returning true if everything went ok- Returns:
- true if everything ok
- Since:
- 0.9.25
-
waitForStreamStatusReply
public boolean waitForStreamStatusReply()Wait for the stream to be created, returning true if everything went ok- Returns:
- true if everything ok
-
waitForNamingReply
Return the destination found matching the name, or null if the key was not able to be retrieved.- Parameters:
name
- name to be looked for, or "ME"- Returns:
- destination found matching the name, or null
-