Search in sources :

Example 1 with ApiAuthSession

use of im.actor.core.api.ApiAuthSession in project actor-platform by actorapp.

the class JsFacade method loadSessions.

@UsedByApp
public JsPromise loadSessions() {
    return JsPromise.create(new JsPromiseExecutor() {

        @Override
        public void execute() {
            messenger.loadSessions().start(new CommandCallback<List<ApiAuthSession>>() {

                @Override
                public void onResult(List<ApiAuthSession> res) {
                    JsArray<JsAuthSession> jsSessions = JsArray.createArray().cast();
                    for (ApiAuthSession session : res) {
                        jsSessions.push(JsAuthSession.create(session));
                    }
                    resolve(jsSessions);
                }

                @Override
                public void onError(Exception e) {
                    Log.e(TAG, e);
                    reject(e.getMessage());
                }
            });
        }
    });
}
Also used : JsPromiseExecutor(im.actor.runtime.js.utils.JsPromiseExecutor) ApiAuthSession(im.actor.core.api.ApiAuthSession) List(java.util.List) ArrayList(java.util.ArrayList) CommandCallback(im.actor.core.viewmodel.CommandCallback) RpcException(im.actor.core.network.RpcException) UsedByApp(im.actor.core.js.annotations.UsedByApp)

Aggregations

ApiAuthSession (im.actor.core.api.ApiAuthSession)1 UsedByApp (im.actor.core.js.annotations.UsedByApp)1 RpcException (im.actor.core.network.RpcException)1 CommandCallback (im.actor.core.viewmodel.CommandCallback)1 JsPromiseExecutor (im.actor.runtime.js.utils.JsPromiseExecutor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1