use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class JsFacade method loadArchivedDialogs.
@UsedByApp
private JsPromise loadArchivedDialogs(final boolean init) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.loadArchivedDialogs(init, new RpcCallback<ResponseLoadArchived>() {
@Override
public void onResult(ResponseLoadArchived response) {
JsArray<JsDialogShort> res = JsArray.createArray().cast();
for (ApiDialog d : response.getDialogs()) {
res.push(JsDialogShort.create(messenger.buildPeerInfo(EntityConverter.convert(d.getPeer())), d.getUnreadCount()));
}
Log.d(TAG, "loadArchivedDialogs:result");
resolve(res);
}
@Override
public void onError(RpcException e) {
Log.d(TAG, "loadArchivedDialogs:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class CursorReaderActor method perform.
@Override
protected void perform(final Peer peer, final long date) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
request(new RequestMessageRead(outPeer, date), new RpcCallback<ResponseVoid>() {
@Override
public void onResult(ResponseVoid response) {
onCompleted(peer, date);
}
@Override
public void onError(RpcException e) {
CursorReaderActor.this.onError(peer, date);
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class ContactsModule method removeContact.
public Command<Boolean> removeContact(final int uid) {
return callback -> {
User user = users().getValue(uid);
if (user == null) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
return;
}
request(new RequestRemoveContact(uid, user.getAccessHash()), new RpcCallback<ResponseSeq>() {
@Override
public void onResult(ResponseSeq response) {
ArrayList<Integer> uids = new ArrayList<>();
uids.add(uid);
SeqUpdate update = new SeqUpdate(response.getSeq(), response.getState(), UpdateContactsRemoved.HEADER, new UpdateContactsRemoved(uids).toByteArray());
updates().onUpdateReceived(update);
runOnUiThread(() -> callback.onResult(true));
}
@Override
public void onError(RpcException e) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
}
});
};
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class ContactsModule method addContact.
public Command<Boolean> addContact(final int uid) {
return callback -> {
User user = users().getValue(uid);
if (user == null) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
return;
}
request(new RequestAddContact(uid, user.getAccessHash()), new RpcCallback<ResponseSeq>() {
@Override
public void onResult(ResponseSeq response) {
ArrayList<Integer> uids = new ArrayList<>();
uids.add(uid);
SeqUpdate update = new SeqUpdate(response.getSeq(), response.getState(), UpdateContactsAdded.HEADER, new UpdateContactsAdded(uids).toByteArray());
updates().onUpdateReceived(update);
runOnUiThread(() -> callback.onResult(true));
}
@Override
public void onError(RpcException e) {
runOnUiThread(() -> callback.onError(new RpcInternalException()));
}
});
};
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class MessageDeleteActor method performDelete.
public void performDelete(final Peer peer, final List<Long> rids) {
final ApiOutPeer outPeer = buidOutPeer(peer);
final ApiPeer apiPeer = buildApiPeer(peer);
request(new RequestDeleteMessage(outPeer, rids), new RpcCallback<ResponseSeq>() {
@Override
public void onResult(ResponseSeq response) {
if (deleteStorage.getPendingDeletions().containsKey(peer)) {
deleteStorage.getPendingDeletions().get(peer).getRids().removeAll(rids);
saveStorage();
}
updates().onUpdateReceived(new SeqUpdate(response.getSeq(), response.getState(), UpdateMessageDelete.HEADER, new UpdateMessageDelete(apiPeer, rids).toByteArray()));
}
@Override
public void onError(RpcException e) {
}
});
}
Aggregations