Class WebSocketInterceptor

  • All Implemented Interfaces:
    okhttp3.Interceptor

    
    public final class WebSocketInterceptor
     implements Interceptor
                        

    Interceptor for WebSocket request, it will add authorization header with token to the request.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Response intercept(Interceptor.Chain chain)
      • Methods inherited from class java.lang.Object

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

      • WebSocketInterceptor

        WebSocketInterceptor(String destination, OAuth2TokenStore tokenStore, Function1<String, OAuth2Token> fetchToken)
        Parameters:
        destination - the optional destination name to fetch token for, it will be used to build the token url, like: {backendUrl}/mobileservices/{applicationId}/{destination}/oauthtoken
        tokenStore - the token store to get and store token, it will be used to get token from store first before fetching new one
        fetchToken - the optional function to fetch new token, it will be called when there is no token in store or the token in store is expired, if not provided, it will use the default implementation to fetch token from server with the default token url
    • Method Detail

      • intercept

         Response intercept(Interceptor.Chain chain)