Search in sources :

Example 6 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class PresenceActor method subscribe.

@Verified
private void subscribe(Peer peer) {
    if (peer.getPeerType() == PeerType.PRIVATE) {
        // Already subscribed
        if (uids.contains(peer.getPeerId())) {
            return;
        }
        User user = getUser(peer.getPeerId());
        if (user == null) {
            return;
        }
        // Subscribing to user online sates
        uids.add(user.getUid());
    } else if (peer.getPeerType() == PeerType.GROUP) {
        // Already subscribed
        if (gids.contains(peer.getPeerId())) {
            return;
        }
        Group group = getGroup(peer.getPeerId());
        if (group == null) {
            return;
        }
        // Ignore subscription to channels
        if (group.getGroupType() == GroupType.CHANNEL) {
            return;
        }
        // Subscribing to group online sates
        gids.add(peer.getPeerId());
    } else {
        return;
    }
    // Adding Pending Peer
    if (pendingPeers.contains(peer)) {
        return;
    }
    pendingPeers.add(peer);
    onCheckQueue();
}
Also used : Group(im.actor.core.entity.Group) User(im.actor.core.entity.User) Verified(im.actor.runtime.annotations.Verified)

Example 7 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class MessagesProcessor method onDifferenceMessages.

@Verified
public Promise<Void> onDifferenceMessages(ApiPeer _peer, List<UpdateMessage> messages) {
    Peer peer = convert(_peer);
    ArrayList<Message> nMessages = new ArrayList<>();
    for (UpdateMessage u : messages) {
        AbsContent msgContent = AbsContent.fromMessage(u.getMessage());
        nMessages.add(new Message(u.getRid(), u.getDate(), u.getDate(), u.getSenderUid(), myUid() == u.getSenderUid() ? MessageState.SENT : MessageState.UNKNOWN, msgContent));
    }
    return context().getMessagesModule().getRouter().onNewMessages(peer, nMessages);
}
Also used : UpdateMessage(im.actor.core.api.updates.UpdateMessage) UpdateMessage(im.actor.core.api.updates.UpdateMessage) ApiMessage(im.actor.core.api.ApiMessage) Message(im.actor.core.entity.Message) ApiPeer(im.actor.core.api.ApiPeer) Peer(im.actor.core.entity.Peer) ArrayList(java.util.ArrayList) AbsContent(im.actor.core.entity.content.AbsContent) Verified(im.actor.runtime.annotations.Verified)

Example 8 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class PresenceActor method onUserLastSeen.

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

Example 9 with Verified

use of im.actor.runtime.annotations.Verified in project actor-platform by actorapp.

the class PresenceActor method onUserOffline.

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

Example 10 with Verified

use of im.actor.runtime.annotations.Verified 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

Verified (im.actor.runtime.annotations.Verified)14 Dialog (im.actor.core.entity.Dialog)5 UserVM (im.actor.core.viewmodel.UserVM)4 ContentDescription (im.actor.core.entity.ContentDescription)3 DialogBuilder (im.actor.core.entity.DialogBuilder)3 Message (im.actor.core.entity.Message)3 Peer (im.actor.core.entity.Peer)3 UserPresence (im.actor.core.viewmodel.UserPresence)3 ArrayList (java.util.ArrayList)3 ApiAvatar (im.actor.core.api.ApiAvatar)2 ApiBotCommand (im.actor.core.api.ApiBotCommand)2 ApiContactRecord (im.actor.core.api.ApiContactRecord)2 ApiMapValue (im.actor.core.api.ApiMapValue)2 ApiUser (im.actor.core.api.ApiUser)2 ApiUserOutPeer (im.actor.core.api.ApiUserOutPeer)2 RequestLoadFullUsers (im.actor.core.api.rpc.RequestLoadFullUsers)2 ResponseLoadFullUsers (im.actor.core.api.rpc.ResponseLoadFullUsers)2 UpdateContactRegistered (im.actor.core.api.updates.UpdateContactRegistered)2 UpdateUserAboutChanged (im.actor.core.api.updates.UpdateUserAboutChanged)2 UpdateUserAvatarChanged (im.actor.core.api.updates.UpdateUserAvatarChanged)2