Name: Android-DDP
Owner: Rocket.Chat
Description: null
Created: 2015-12-17 14:32:48.0
Updated: 2018-05-22 05:12:48.0
Pushed: 2016-11-13 03:43:17.0
Homepage: null
Size: 411
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Promise-styled Android DDP implementation with Bolts-Android/RxJava.
in build.gradle
rojects {
repositories {
jcenter()
maven { url 'https://github.com/RocketChat/Android-DDP/raw/master/repository' } // for Android-DDP
}
in app/build.gradle
ndencies {
compile 'chat.rocket:android-ddp:0.0.8'
HttpClient wsClient = new OkHttpClient().setReadTimeout(0, TimeUnit.NANOSECONDS);
PClient ddpClient = new DDPClient(wsClient);
connect to ddp server.
pClient.connect("wss://demo.rocket.chat/websocket").onSuccessTask(task -> {
DDPClientCallback.Connect result = task.getResult();
// observe all callback events.
result.client.getSubscriptionCallback().subscribe(event -> {
Log.d(TAG,"Callback [DEBUG] < "+ event);
});
// observe all callback events.
result.client.getFailureObservable().subscribe(event -> {
Log.w(TAG,"disconnected!");
});
// next try to login with token
return result.client.rpc("login", new JSONArray().put(token) ,"2", 4000);
.onSuccess(task -> {
DDPClientCallback.Connect result = task.getResult();
Log.d(TAG, "Login succeeded.");
.continueWith(task -> {
if(task.isFaulted()){
if (task.getError instanceof DDPClientCallback.Connect.Error) {
Log.e(TAG, "failed to connect.", task.getError());
}
if (task.getError instanceof DDPClientCallback.RPC.Error) {
Log.e(TAG, "failed to login.", task.getError());
}
}
return null;
;