Class OkHttpWebSocketClient

java.lang.Object
okhttp3.WebSocketListener
com.alibaba.dashscope.legacy_2x.protocol.okhttp.OkHttpWebSocketClient
All Implemented Interfaces:
FullDuplexClient, HalfDuplexClient
Direct Known Subclasses:
OkHttpWebSocketClientForAudio

@Deprecated public class OkHttpWebSocketClient extends okhttp3.WebSocketListener implements HalfDuplexClient, FullDuplexClient
Deprecated.
  • Field Details

    • isClosed

      protected AtomicBoolean isClosed
      Deprecated.
    • isFirstMessage

      protected AtomicBoolean isFirstMessage
      Deprecated.
    • responseEmitter

      protected volatile io.reactivex.FlowableEmitter<DashScopeResult> responseEmitter
      Deprecated.
    • streamingDataDisposable

      protected volatile io.reactivex.disposables.Disposable streamingDataDisposable
      Deprecated.
  • Constructor Details

    • OkHttpWebSocketClient

      public OkHttpWebSocketClient(okhttp3.OkHttpClient client, boolean passTaskStarted)
      Deprecated.
  • Method Details

    • getRequestIdOrUnknown

      protected String getRequestIdOrUnknown()
      Deprecated.
    • close

      public boolean close(int code, String reason)
      Deprecated.
      Specified by:
      close in interface FullDuplexClient
      Specified by:
      close in interface HalfDuplexClient
    • cancel

      public void cancel()
      Deprecated.
      close websocket connection see. https://square.github.io/okhttp/3.x/okhttp/okhttp3/WebSocket.html
      Specified by:
      cancel in interface FullDuplexClient
    • intSetting

      protected static int intSetting(String systemProperty, String envName, int defaultValue)
      Deprecated.
      Reads an int setting from the system property first, then from the environment variable, and falls back to the default value when both are absent or malformed.
    • onClosed

      public void onClosed(okhttp3.WebSocket webSocket, int code, String reason)
      Deprecated.
      Overrides:
      onClosed in class okhttp3.WebSocketListener
    • onClosing

      public void onClosing(okhttp3.WebSocket webSocket, int code, String reason)
      Deprecated.
      Overrides:
      onClosing in class okhttp3.WebSocketListener
    • onFailure

      public void onFailure(okhttp3.WebSocket webSocket, Throwable t, okhttp3.Response response)
      Deprecated.
      Overrides:
      onFailure in class okhttp3.WebSocketListener
    • onMessage

      public void onMessage(okhttp3.WebSocket webSocket, String text)
      Deprecated.
      Overrides:
      onMessage in class okhttp3.WebSocketListener
    • onMessage

      public void onMessage(okhttp3.WebSocket webSocket, okio.ByteString bytes)
      Deprecated.
      Overrides:
      onMessage in class okhttp3.WebSocketListener
    • onOpen

      public void onOpen(okhttp3.WebSocket webSocket, okhttp3.Response response)
      Deprecated.
      Overrides:
      onOpen in class okhttp3.WebSocketListener
    • sendTextWithRetry

      protected void sendTextWithRetry(String apiKey, boolean isSecurityCheck, String message, String workspace, Map<String,String> customHeaders, String baseWebSocketUrl, String module)
      Deprecated.
    • sendBinaryWithRetry

      protected void sendBinaryWithRetry(String apiKey, boolean isSecurityCheck, okio.ByteString message, String workspace, Map<String,String> customHeaders, String baseWebSocketUrl, String module)
      Deprecated.
    • send

      Deprecated.
      Description copied from interface: HalfDuplexClient
      Blocking send http request and get the response body.
      Specified by:
      send in interface HalfDuplexClient
      Parameters:
      req - the user input data and parameters.
      Returns:
      The the `DashScopeResult`.
    • send

      public void send(HalfDuplexRequest req, ResultCallback<DashScopeResult> callback)
      Deprecated.
      Specified by:
      send in interface HalfDuplexClient
    • streamOut

      public io.reactivex.Flowable<DashScopeResult> streamOut(HalfDuplexRequest req)
      Deprecated.
      Specified by:
      streamOut in interface HalfDuplexClient
    • streamOut

      public void streamOut(HalfDuplexRequest req, ResultCallback<DashScopeResult> callback)
      Deprecated.
      Specified by:
      streamOut in interface HalfDuplexClient
    • onBeforeSendStartMessage

      protected void onBeforeSendStartMessage(com.google.gson.JsonObject startMessage)
      Deprecated.
      Hook method called before sending the start message. Subclasses may override to add additional logging or pre-processing.
    • emitResponseError

      protected void emitResponseError(Throwable error)
      Deprecated.
      Publishes a terminal error on the response stream. When no subscriber is attached yet, the error is parked and replayed as soon as one subscribes: a failure raised early, a handshake refused by the server for instance, can otherwise be reported before the caller of duplex() had the chance to subscribe, which would leave that caller waiting forever.
    • executeStreamRequest

      protected void executeStreamRequest(FullDuplexRequest req)
      Deprecated.
      Core streaming request logic. Extracted to allow subclasses to use different executors.
    • sendStreamRequest

      protected CompletableFuture<Void> sendStreamRequest(FullDuplexRequest req)
      Deprecated.
    • streamIn

      public DashScopeResult streamIn(FullDuplexRequest req)
      Deprecated.
      Specified by:
      streamIn in interface FullDuplexClient
    • streamIn

      public void streamIn(FullDuplexRequest req, ResultCallback<DashScopeResult> callback) throws NoApiKeyException, ApiException
      Deprecated.
      Specified by:
      streamIn in interface FullDuplexClient
      Throws:
      NoApiKeyException
      ApiException
    • duplex

      public io.reactivex.Flowable<DashScopeResult> duplex(FullDuplexRequest req) throws NoApiKeyException, ApiException
      Deprecated.
      Specified by:
      duplex in interface FullDuplexClient
      Throws:
      NoApiKeyException
      ApiException
    • duplex

      public void duplex(FullDuplexRequest req, ResultCallback<DashScopeResult> callback) throws NoApiKeyException, ApiException
      Deprecated.
      Specified by:
      duplex in interface FullDuplexClient
      Throws:
      NoApiKeyException
      ApiException