MCPcopy
hub / github.com/tinode/chat / sessToForeground

Method sessToForeground

server/topic.go:865–886  ·  view source on GitHub ↗

sessToForeground updates perUser online status accounting and fires due deferred notifications for the provided session.

(sess *Session)

Source from the content-addressed store, hash-verified

863// sessToForeground updates perUser online status accounting and fires due
864// deferred notifications for the provided session.
865func (t *Topic) sessToForeground(sess *Session) {
866 s := sess
867 if s.multi != nil {
868 s = s.multi
869 }
870
871 if pssd, ok := t.sessions[s]; ok && !pssd.isChanSub {
872 uid := pssd.uid
873 if s.isMultiplex() {
874 // If 's' is a multiplexing session, then sess is a proxy and it contains correct UID.
875 // Add UID to the list of online users.
876 uid = sess.uid
877 pssd.muids = append(pssd.muids, uid)
878 }
879 // Mark user as online
880 pud := t.perUser[uid]
881 pud.online++
882 t.perUser[uid] = pud
883
884 t.sendSubNotifications(uid, sess.sid, sess.userAgent)
885 }
886}
887
888// Send immediate presence notification in response to a subscription.
889// Send push notification to the P2P counterpart.

Callers 1

handleSessionUpdateMethod · 0.95

Calls 2

sendSubNotificationsMethod · 0.95
isMultiplexMethod · 0.80

Tested by

no test coverage detected