Class ReplyEvent

java.lang.Object
java.util.EventObject
cl.netswitch.lib.client.ReplyEvent
All Implemented Interfaces:
Serializable

public final class ReplyEvent extends EventObject
ReplyEvent is used to notify that a reply message has arrived.
See Also:
  • Constructor Details

    • ReplyEvent

      public ReplyEvent(ClientChannel channel, Message message)
      Constructs a new ReplyEvent instance.
      Parameters:
      channel - the object on which the event occurred.
      message - the reply message of this event.
      Throws:
      NullPointerException - if an argument is null.
  • Method Details

    • getClientChannel

      public ClientChannel getClientChannel()
      Returns the client channel of this event.
      Returns:
      the client channel of this event.
    • getMessage

      public Message getMessage()
      Returns the reply message of this event.
      Returns:
      the reply message of this event.
    • getSuccessMessage

      public Message getSuccessMessage()
      Returns the reply message with a SUCCESS status. It throws a ClientException if the status of the message is an ERROR. The ClientException includes the status, text and userMessage of the reply message.
      Returns:
      the success reply message of this event.
      Throws:
      ReplyTimeoutException - if the reply timeout.
      ClientException - if the reply message has an error status.
    • getObject

      public <T extends Serializable> T getObject(Class<T> type)
      Returns the object contained in the success message of this ReplyEvent.

      Warning: to reduce memory consumption, this method returns a reference to (not a copy of) the mutable object stored in the reply message. If the returned object is later modified, the reply message object will be modified.

      Type Parameters:
      T - the type of the returned object.
      Parameters:
      type - the class of the returned object.
      Returns:
      a typed object or null if not defined.
      Throws:
      NullPointerException - if type is null.
      ReplyTimeoutException - if the reply timeout.
      ClientException - if the reply message has an error status.
      ClassCastException - if object is not an instance of type.
      See Also: