-
Notifications
You must be signed in to change notification settings - Fork 4
Initialize BandyerSDKClient
Kristiyan Petrov edited this page Jan 23, 2019
·
23 revisions
The BandyerSDKClient is the object accountable for everything regarding the communication.
BandyerSDKClientOptions options = new BandyerSDKClientOptions.Builder().build();
BandyerSDKClient.getInstance().init(userAlias, options);
BandyerSDKClient.getInstance().startListening(); // Start listening for incoming events
BandyerSDKClient.getInstance().stopListening(); // Stop listening for incoming events
Remember to call this method to ensure a clean exit from the activity.
BandyerSDKClient.getInstance().dispose();
Call this method to delete all the local data saved for the userAlias used for the BandyerSDKClient initialization.
BandyerSDKClient.getInstance().clearUserCache();
There are two types of observers
- An Observer for the overall client events
BandyerSDKClient.getInstance().addObserver(new BandyerSDKClientObserver() {
@Override
public void onClientStatusChange(BandyerSDKClientState state) {
Log.d(TAG, "Bandyer SDK client status change: " + state);
}
@Override
public void onClientError(Throwable throwable) {
Log.d(TAG, "Bandyer SDK client error " + throwable.getMessage());
}
@Override
public void onClientReady() {
Log.d(TAG, "Bandyer SDK client ready.");
}
@Override
public void onClientStopped() {
Log.d(TAG, "Bandyer SDK client stopped.");
}
});
- An Observer for the modules(call and/or chat)
BandyerSDKClient.getInstance().addModuleObserver(new BandyerModuleObserver() {
@Override
public void onModuleReady(BandyerModule module) {
if (module instanceof ChatModule) {
Log.d(TAG, "chat module ready! It is now possible to start a call.");
} else if (module instanceof CallModule) {
Log.d(TAG, "call module ready! It is now possible to start a chat.");
}
}
@Override
public void onModulePaused(BandyerModule module) {
Log.d(TAG, "module " + module.getName() + " paused.");
}
@Override
public void onModuleFailed(BandyerModule module, Throwable throwable) {
Log.d(TAG, "module " + module.getName() + " failed with error " + throwable.getMessage());
}
@Override
public void onModuleStatusChanged(BandyerModule module, BandyerModuleStatus moduleStatus) {
Log.d(TAG, "module " + module.getName() + " status change: " + moduleStatus);
}
});