Package 

Interface Call

  • All Implemented Interfaces:
    java.lang.Cloneable

    
    public interface Call
     implements Cloneable
                        

    A call is a mobonRequest that has been prepared for execution. A call can be canceled. As this object represents a single mobonRequest/response pair (stream), it cannot be executed twice.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public interface Call.Factory
    • Method Summary

      Modifier and Type Method Description
      abstract MobonRequest request() Returns the original mobonRequest that initiated this call.
      abstract MobonResponse execute() Invokes the mobonRequest immediately, and blocks until the response can be processed or is inerror.
      abstract void enqueue(Callback responseCallback) Schedules the mobonRequest to be executed at some point in the future.
      abstract void cancel() Cancels the mobonRequest, if possible.
      abstract boolean isExecuted() Returns true if this call has been either executed or enqueued.
      abstract boolean isCanceled()
      abstract Call clone() Create a new, identical call to this one which can be enqueued or executed even if this callhas already been.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • request

         abstract MobonRequest request()

        Returns the original mobonRequest that initiated this call.

      • execute

         abstract MobonResponse execute()

        Invokes the mobonRequest immediately, and blocks until the response can be processed or is inerror.

        To avoid leaking resources callers should close the MobonResponse which in turn willclose the underlying ResponseBody.

        {@code * * // ensure the response (and underlying response body) is closed * try (MobonResponse response = client.newCall(mobonRequest).execute()) { * ... * } * * }

        The caller may read the response body with the response's body method. Toavoid leaking resources callers must close the response body or theMobonResponse.

        Note that transport-layer success (receiving a HTTP response code, headers and body) doesnot necessarily indicate application-layer success: {@code response} may still indicate anunhappy HTTP response code like 404 or 500.

      • enqueue

         abstract void enqueue(Callback responseCallback)

        Schedules the mobonRequest to be executed at some point in the future.

        The dispatcher defines when the mobonRequest will run: usuallyimmediately unless there are several other requests currently being executed.

        This client will later call back {@code responseCallback} with either an HTTP response or afailure exception.

      • cancel

         abstract void cancel()

        Cancels the mobonRequest, if possible. Requests that are already complete cannot be canceled.

      • isExecuted

         abstract boolean isExecuted()

        Returns true if this call has been either executed or enqueued. It is an error to execute a call more than once.

      • clone

         abstract Call clone()

        Create a new, identical call to this one which can be enqueued or executed even if this callhas already been.