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 and Description
    `SAMEventHandler(I2PAppContext ctx)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and 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 ADD
    `void` | `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 ok
    `String` | `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 ok
    `boolean` | `waitForSessionCreateReply()` Wait for the session to be created, returning true if everything went ok
    `boolean` | `waitForStreamStatusReply()` Wait for the stream to be created, returning true if everything went ok

    - ### Methods inherited from class net.i2p.sam.client.SAMClientEventListenerImpl

      `datagramReceived, destReplyReceived, pingReceived, pongReceived, rawReceived, streamClosedReceived, streamConnectedReceived, streamDataReceived`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SAMEventHandler

          public SAMEventHandler(I2PAppContext ctx)

  - ### Method Detail

    - #### helloReplyReceived

          public void helloReplyReceived(boolean ok,
                                         String version)

      Specified by:
        `helloReplyReceived` in interface `SAMReader.SAMClientEventListener`
      Overrides:
        `helloReplyReceived` in class `SAMClientEventListenerImpl`

    - #### namingReplyReceived

          public void namingReplyReceived(String name,
                                          String result,
                                          String value,
                                          String msg)

      Specified by:
        `namingReplyReceived` in interface `SAMReader.SAMClientEventListener`
      Overrides:
        `namingReplyReceived` in class `SAMClientEventListenerImpl`

    - #### sessionStatusReceived

          public void sessionStatusReceived(String result,
                                            String destination,
                                            String msg)

      may be called twice, first for CREATE and second for ADD
      Specified by:
        `sessionStatusReceived` in interface `SAMReader.SAMClientEventListener`
      Overrides:
        `sessionStatusReceived` in class `SAMClientEventListenerImpl`

    - #### streamStatusReceived

          public void streamStatusReceived(String result,
                                           String id,
                                           String message)

      Specified by:
        `streamStatusReceived` in interface `SAMReader.SAMClientEventListener`
      Overrides:
        `streamStatusReceived` in class `SAMClientEventListenerImpl`

    - #### unknownMessageReceived

          public void unknownMessageReceived(String major,
                                             String minor,
                                             Properties params)

      Specified by:
        `unknownMessageReceived` in interface `SAMReader.SAMClientEventListener`
      Overrides:
        `unknownMessageReceived` in class `SAMClientEventListenerImpl`

    - #### waitForHelloReply

          public String 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

    - #### waitForNamingReply

          public String waitForNamingReply(String name)

      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

    - #### waitForSessionAddReply

          public boolean waitForSessionAddReply()

      Wait for the session to be added, returning true if everything went ok
      Returns:
        true if everything ok

    - #### waitForSessionCreateReply

          public boolean waitForSessionCreateReply()

      Wait for the session to be created, returning true if everything went ok
      Returns:
        true if everything ok

    - #### waitForStreamStatusReply

          public boolean waitForStreamStatusReply()

      Wait for the stream to be created, returning true if everything went ok
      Returns:
        true if everything ok