use of im.actor.core.api.rpc.ResponseVoid in project actor-platform by actorapp.
the class CursorReceiverActor method perform.
@Override
protected void perform(final Peer peer, final long date) {
ApiOutPeer outPeer = buidOutPeer(peer);
if (outPeer == null) {
return;
}
request(new RequestMessageReceived(outPeer, date), new RpcCallback<ResponseVoid>() {
@Override
public void onResult(ResponseVoid response) {
onCompleted(peer, date);
}
@Override
public void onError(RpcException e) {
CursorReceiverActor.this.onError(peer, date);
}
});
}
use of im.actor.core.api.rpc.ResponseVoid in project actor-platform by actorapp.
the class KeyManagerActor method onMainKeysReady.
private void onMainKeysReady() {
Log.d(TAG, "Main Keys are ready");
//
// Generation required pre keys
//
int missingKeysCount = Math.max(0, Configuration.EPHEMERAL_KEYS_COUNT - ownKeys.getPreKeys().length);
if (missingKeysCount > 0) {
ownKeys = ownKeys.appendPreKeys(ManagedList.of(PrivateKey.GENERATOR, missingKeysCount).toArray(new PrivateKey[0]));
encryptionKeysStorage.addOrUpdateItem(0, ownKeys.toByteArray());
}
//
// Uploading own pre keys
//
final ManagedList<PrivateKey> pendingEphermalKeys = ManagedList.of(ownKeys.getPreKeys()).filter(PrivateKey.NOT_UPLOADED);
if (pendingEphermalKeys.size() > 0) {
ArrayList<ApiEncryptionKey> uploadingKeys = pendingEphermalKeys.map(PrivateKey.TO_API);
ArrayList<ApiEncryptionKeySignature> uploadingSignatures = pendingEphermalKeys.map(PrivateKey.SIGN(ownKeys.getIdentityKey()));
api(new RequestUploadPreKey(ownKeys.getKeyGroupId(), uploadingKeys, uploadingSignatures)).then(new Consumer<ResponseVoid>() {
@Override
public void apply(ResponseVoid responseVoid) {
ownKeys = ownKeys.markAsUploaded(pendingEphermalKeys.toArray(new PrivateKey[pendingEphermalKeys.size()]));
encryptionKeysStorage.addOrUpdateItem(0, ownKeys.toByteArray());
onAllKeysReady();
}
}).failure(new Consumer<Exception>() {
@Override
public void apply(Exception e) {
Log.w(TAG, "Ephemeral keys upload error");
Log.e(TAG, e);
// Ignore. This will freeze all encryption operations.
}
});
} else {
onAllKeysReady();
}
}
use of im.actor.core.api.rpc.ResponseVoid 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.api.rpc.ResponseVoid in project actor-platform by actorapp.
the class PresenceActor method onCheckQueue.
private void onCheckQueue() {
if (isRequesting) {
return;
}
if (pendingPeers.size() == 0) {
return;
}
ArrayList<Peer> destPeers = new ArrayList<>(pendingPeers);
pendingPeers.clear();
ArrayList<ApiUserOutPeer> outUserPeers = new ArrayList<>();
ArrayList<ApiGroupOutPeer> outGroupPeers = new ArrayList<>();
for (Peer p : destPeers) {
if (p.getPeerType() == PeerType.GROUP) {
Group g = getGroup(p.getPeerId());
if (g != null) {
outGroupPeers.add(new ApiGroupOutPeer(p.getPeerId(), g.getAccessHash()));
}
} else if (p.getPeerType() == PeerType.PRIVATE) {
User u = getUser(p.getPeerId());
if (u != null) {
outUserPeers.add(new ApiUserOutPeer(p.getPeerId(), u.getAccessHash()));
}
}
}
ArrayList<Promise<ResponseVoid>> requests = new ArrayList<>();
if (outUserPeers.size() > 0) {
requests.add(api(new RequestSubscribeToOnline(outUserPeers)));
}
if (outGroupPeers.size() > 0) {
requests.add(api(new RequestSubscribeToGroupOnline(outGroupPeers)));
}
if (requests.size() > 0) {
isRequesting = true;
PromisesArray.ofPromises(requests).zip().then(responseVoids -> {
isRequesting = false;
onCheckQueue();
}).failure(e -> {
isRequesting = false;
onCheckQueue();
});
}
}
Aggregations