RocketChat/Android-DDP

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Android-DDP

Promise-styled Android DDP implementation with Bolts-Android/RxJava.

gradle integration (testing…)

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'

Usage Example

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;
;


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.