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();
}
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);
}
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();
}
}
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();
}
}
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));
}
Aggregations