use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method deleteChat.
@UsedByApp
public JsPromise deleteChat(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.deleteChat(peer.convert()).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
Log.d(TAG, "deleteChat:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "deleteChat:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method archiveChat.
@UsedByApp
public JsPromise archiveChat(final JsPeer peer) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.archiveChat(peer.convert()).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
Log.d(TAG, "archiveChat:result");
resolve();
}
@Override
public void onError(Exception e) {
Log.d(TAG, "archiveChat:error");
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method terminateSession.
@UsedByApp
public JsPromise terminateSession(final int id) {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.terminateSession(id).start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
resolve();
}
@Override
public void onError(Exception e) {
Log.e(TAG, e);
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class JsFacade method terminateAllSessions.
@UsedByApp
public JsPromise terminateAllSessions() {
return JsPromise.create(new JsPromiseExecutor() {
@Override
public void execute() {
messenger.terminateAllSessions().start(new CommandCallback<Void>() {
@Override
public void onResult(Void res) {
resolve();
}
@Override
public void onError(Exception e) {
Log.e(TAG, e);
reject(e.getMessage());
}
});
}
});
}
use of im.actor.runtime.actors.messages.Void in project actor-platform by actorapp.
the class ContactsSyncActor method performSync.
public void performSync() {
if (ENABLE_LOG) {
Log.d(TAG, "Checking sync");
}
if (isInProgress) {
if (ENABLE_LOG) {
Log.d(TAG, "Sync in progress, invalidating current sync");
}
isInvalidated = true;
return;
}
isInProgress = true;
isInvalidated = false;
if (ENABLE_LOG) {
Log.d(TAG, "Starting sync");
}
Integer[] uids = contacts.toArray(new Integer[contacts.size()]);
Arrays.sort(uids);
String hash = "";
for (long u : uids) {
if (hash.length() != 0) {
hash += ",";
}
hash += u;
}
byte[] hashData;
try {
hashData = hash.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return;
}
String hashValue = Crypto.hex(Crypto.SHA256(hashData));
if (ENABLE_LOG) {
Log.d(TAG, "Performing sync with hash: " + hashValue);
Log.d(TAG, "Performing sync with uids: " + hash);
}
request(new RequestGetContacts(hashValue, ApiSupportConfiguration.OPTIMIZATIONS), new RpcCallback<ResponseGetContacts>() {
@Override
public void onResult(ResponseGetContacts response) {
if (ENABLE_LOG) {
Log.d(TAG, "Sync received " + (response.getUsers().size() + response.getUserPeers().size()) + " contacts");
}
if (response.getUserPeers().size() > 0) {
updates().loadRequiredPeers(response.getUserPeers(), new ArrayList<>()).then(v -> onContactsLoaded(response));
} else {
updates().applyRelatedData(response.getUsers()).then(v -> onContactsLoaded(response));
}
}
@Override
public void onError(RpcException e) {
isInProgress = false;
e.printStackTrace();
}
});
}
Aggregations