Package com.castlabs.sdk.okhttp
Class OkHttpPlugin
- java.lang.Object
-
- com.castlabs.android.Plugin
-
- com.castlabs.sdk.okhttp.OkHttpPlugin
-
public class OkHttpPlugin extends Plugin
This plugin class enables support for OkHttp and uses it to create http connections. You need to register and enable the plugin before you initialize the SDK:
OkHttp can be also used for debugging purposes to intercept and show the network traffic. For that, you will need to add additional dependencies in the applications build script:public class MyApp extends Application {
@
Override public void onCreate() { super.onCreate(); PlayerSDK.register(new OkHttpPlugin()); PlayerSDK.init(getApplicationContext()); } }
With these dependencies in place, you can setup the plugin using the network interceptor:compile 'com.facebook.stetho:stetho:1.3.1' compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
Using this extended setup allows you to use your local chrome development tools to intercept and show network traffic. For that, run the Application on a device connected via USB, start chrome and open a tab on chrome://inspect/#devices. Enable USB discovery and you will see you Application listed. You can now inspect the network traffic of your application.public class MyApp extends Application {
@
Override public void onCreate() { super.onCreate(); Stetho.initializeWithDefaults(this); PlayerSDK.register(new OkHttpPlugin( new OkHttpClient.Builder().addNetworkInterceptor(new StethoInterceptor()))); PlayerSDK.init(getApplicationContext()); } }- Since:
- 3.0.2
-
-
Constructor Summary
Constructors Constructor Description OkHttpPlugin()
Create a new plugin instance that will use the default client builderOkHttpPlugin(okhttp3.OkHttpClient.Builder clientBuilder)
Create a new plugin instance that will use the given builder to create the ok http client instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
enableKeyStoreSetup(boolean enable)
Enable or disable usage ofPlayerSDK.SSL_KEY_STORE
.void
evictIdleConnections()
Close all idle connections using OkHttpString
getId()
-
Methods inherited from class com.castlabs.android.Plugin
init, onRemotePlay
-
-
-
-
Constructor Detail
-
OkHttpPlugin
public OkHttpPlugin()
Create a new plugin instance that will use the default client builder
-
OkHttpPlugin
public OkHttpPlugin(@NonNull okhttp3.OkHttpClient.Builder clientBuilder)
Create a new plugin instance that will use the given builder to create the ok http client instance. You can pass a custom configured builder here, for example to if you want to inject network interceptors for debugging purposes.- Parameters:
clientBuilder
- The client builder
-
-
Method Detail
-
enableKeyStoreSetup
public void enableKeyStoreSetup(boolean enable)
Enable or disable usage ofPlayerSDK.SSL_KEY_STORE
. Default is enabled.- Parameters:
enable
- Providetrue
ifPlayerSDK.SSL_KEY_STORE
should be applied and override SSL socket factory and Trust managers. Will not have any effect ifPlayerSDK.SSL_KEY_STORE
is not set. Providefalse
if your builder contains custom SSL socket factory and should not be overridden
-
evictIdleConnections
public void evictIdleConnections()
Close all idle connections using OkHttp
-
-