Class GlobalRequestFuture

All Implemented Interfaces:
EventListener, SshFuture<GlobalRequestFuture>, SshFutureListener<IoWriteFuture>, WaitableFuture, SshdEventListener

public class GlobalRequestFuture extends DefaultSshFuture<GlobalRequestFuture> implements SshFutureListener<IoWriteFuture>
A DefaultSshFuture that can be used to wait for the reply of an SSH_MSG_GLOBAL_REQUEST sent with want-reply = true.
  • Field Details

  • Constructor Details

    • GlobalRequestFuture

      public GlobalRequestFuture(String request)
      Creates a new GlobalRequestFuture for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the reply has been received or an error occurred.
      Parameters:
      request - the request identifier
    • GlobalRequestFuture

      public GlobalRequestFuture(String request, GlobalRequestFuture.ReplyHandler handler)
      Creates a new GlobalRequestFuture for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the request has been sent, or an error occurred during sending. The framework will invoke the handler once the reply has been received. For global requests with want-reply = false, the handler will be invoked with an empty buffer if the request was successfully sent.
      Parameters:
      request - the request identifier
      handler - the GlobalRequestFuture.ReplyHandler, or null
  • Method Details

    • getId

      public String getId()
      Specified by:
      getId in interface WaitableFuture
      Overrides:
      getId in class AbstractSshFuture<GlobalRequestFuture>
      Returns:
      Some identifier useful as toString() value
    • getSequenceNumber

      public long getSequenceNumber()
      Retrieves this future's packet sequence number.
      Returns:
      the sequence number
    • setSequenceNumber

      public void setSequenceNumber(long number)
      Sets the packet sequence number of the global request represented by this future.
      Parameters:
      number - the packet sequence number
      Throws:
      IllegalArgumentException - if the number given is not an unsigned 32bit value
    • fail

      public void fail(String message)
      Fulfills this future, marking it as failed.
      Parameters:
      message - An explanation of the failure reason
    • getHandler

      public GlobalRequestFuture.ReplyHandler getHandler()
      Retrieves the GlobalRequestFuture.ReplyHandler of this future, if any.
      Returns:
      the handler, or null if none was set
    • getBuffer

      public Buffer getBuffer()
      Obtains the reply Buffer if the request was successful. If called after DefaultSshFuture.isDone() is true, a non-null result means the request was successful.
      Returns:
      the Buffer, or null if the request was not successful or the reply was not received yet
    • getException

      public Throwable getException()
      Retrieves an exception if the request failed. If called after DefaultSshFuture.isDone() is true, a null result means the request did not fail.
      Returns:
      a failure reason, or null if there isn't one or if the request did not fail
    • operationComplete

      public void operationComplete(IoWriteFuture future)
      Description copied from interface: SshFutureListener
      Invoked when the operation associated with the SshFuture has been completed even if you add the listener after the completion.
      Specified by:
      operationComplete in interface SshFutureListener<IoWriteFuture>
      Parameters:
      future - The source SshFuture which called this callback.
    • toString

      public String toString()
      Overrides:
      toString in class DefaultSshFuture<GlobalRequestFuture>