Package com.castlabs.sdk.okhttp
Class OkHttpPlugin
java.lang.Object
com.castlabs.android.Plugin
com.castlabs.sdk.okhttp.OkHttpPlugin
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:
public class MyApp extends Application {
@
Override
public void onCreate() {
super.onCreate();
PlayerSDK.register(new OkHttpPlugin());
PlayerSDK.init(getApplicationContext());
}
}
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:
compile 'com.facebook.stetho:stetho:1.3.1'
compile 'com.facebook.stetho:stetho-okhttp3:1.3.1'
With these dependencies in place, you can setup the plugin using the network interceptor:
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());
}
}
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.- Since:
- 3.0.2
-
Constructor Summary
ConstructorDescriptionCreate 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
Modifier and TypeMethodDescriptionvoid
enableKeyStoreSetup
(boolean enable) Enable or disable usage ofPlayerSDK.SSL_KEY_STORE
.void
Close all idle connections using OkHttpgetId()
Methods inherited from class com.castlabs.android.Plugin
init, onRemotePlay
-
Constructor Details
-
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 Details
-
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 -
getId
-