Search in sources :

Example 6 with UserPresence

use of im.actor.core.viewmodel.UserPresence in project actor-platform by actorapp.

the class PresenceActor method onUserOnline.

@Verified
private void onUserOnline(int uid, long updateDate) {
    // Log.d(TAG, "onUserOnline  #" + uid + " at " + updateDate);
    if (lastUidState.containsKey(uid) && lastUidState.get(uid) >= updateDate) {
        // Log.d(TAG, "onUserOnline:ignored - too old");
        return;
    }
    lastUidState.put(uid, updateDate);
    // Log.d(TAG, "onUserOnline:updated");
    UserVM vm = getUserVM(uid);
    if (vm != null) {
        vm.getPresence().change(new UserPresence(UserPresence.State.ONLINE));
    }
    // Updating timeout
    if (uidCancellables.containsKey(uid)) {
        uidCancellables.remove(uid).cancel();
    }
    uidCancellables.put(uid, schedule(new OnlineUserTimeout(uid, (int) ((updateDate + ONLINE_TIMEOUT) / 1000L), updateDate + ONLINE_TIMEOUT), ONLINE_TIMEOUT));
}
Also used : UserVM(im.actor.core.viewmodel.UserVM) UserPresence(im.actor.core.viewmodel.UserPresence) Verified(im.actor.runtime.annotations.Verified)

Aggregations

UserPresence (im.actor.core.viewmodel.UserPresence)6 UserVM (im.actor.core.viewmodel.UserVM)5 Verified (im.actor.runtime.annotations.Verified)3 Avatar (im.actor.core.entity.Avatar)1 JsOnlineUser (im.actor.core.js.entity.JsOnlineUser)1 UserEmail (im.actor.core.viewmodel.UserEmail)1 UserPhone (im.actor.core.viewmodel.UserPhone)1 ArrayListUserEmail (im.actor.core.viewmodel.generics.ArrayListUserEmail)1 ArrayListUserPhone (im.actor.core.viewmodel.generics.ArrayListUserPhone)1