use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class SenderActor method performSendApiContent.
private void performSendApiContent(final Peer peer, final long rid, ApiMessage message, final WakeLock wakeLock) {
final ApiOutPeer outPeer = buidOutPeer(peer);
final ApiPeer apiPeer = buildApiPeer(peer);
if (outPeer == null || apiPeer == null) {
return;
}
request(new RequestSendMessage(outPeer, rid, message, null, null), new RpcCallback<ResponseSeqDate>() {
@Override
public void onResult(ResponseSeqDate response) {
self().send(new MessageSent(peer, rid));
updates().onUpdateReceived(new SeqUpdate(response.getSeq(), response.getState(), UpdateMessageSent.HEADER, new UpdateMessageSent(apiPeer, rid, response.getDate()).toByteArray()));
wakeLock.releaseLock();
}
@Override
public void onError(RpcException e) {
self().send(new MessageError(peer, rid));
wakeLock.releaseLock();
}
});
}
use of im.actor.core.network.RpcException in project actor-platform by actorapp.
the class SettingsSyncActor method preStart.
@Override
public void preStart() {
super.preStart();
syncState = new SettingsSyncState();
byte[] data = preferences().getBytes(SYNC_STATE);
if (data != null) {
try {
syncState = SettingsSyncState.fromBytes(data);
} catch (IOException e) {
e.printStackTrace();
}
}
for (SettingsSyncAction action : syncState.getPendingActions()) {
performSync(action);
}
if (!preferences().getBool(SYNC_STATE_LOADED, false)) {
// TODO: Avoid race conditions
request(new RequestGetParameters(), new RpcCallback<ResponseGetParameters>() {
@Override
public void onResult(ResponseGetParameters response) {
for (ApiParameter p : response.getParameters()) {
context().getSettingsModule().onUpdatedSetting(p.getKey(), p.getValue());
}
context().getSettingsModule().notifySettingsChanged();
preferences().putBool(SYNC_STATE_LOADED, true);
context().getConductor().getConductor().onSettingsLoaded();
}
@Override
public void onError(RpcException e) {
// Ignore
}
});
} else {
context().getConductor().getConductor().onSettingsLoaded();
}
}
Aggregations