Disconnects session from topic if either one of the following is true: * 's' is an ordinary session AND ('asUid' is zero OR 'asUid' matches subscribed user). * 's' is a multiplexing session and it's being dropped all together ('asUid' is zero ). If 's' is a multiplexing session and asUid is not zero
(sess *Session, asUid types.Uid)
| 3916 | // users 'muids'. |
| 3917 | // Returns perSessionData if it was found and true if session was actually detached from topic. |
| 3918 | func (t *Topic) remSession(sess *Session, asUid types.Uid) (*perSessionData, bool) { |
| 3919 | s := sess |
| 3920 | if sess.multi != nil { |
| 3921 | s = s.multi |
| 3922 | } |
| 3923 | pssd, ok := t.sessions[s] |
| 3924 | if !ok { |
| 3925 | // Session not found at all. |
| 3926 | return nil, false |
| 3927 | } |
| 3928 | |
| 3929 | if pssd.uid == asUid || asUid.IsZero() { |
| 3930 | delete(t.sessions, s) |
| 3931 | return &pssd, true |
| 3932 | } |
| 3933 | |
| 3934 | for i := range pssd.muids { |
| 3935 | if pssd.muids[i] == asUid { |
| 3936 | pssd.muids[i] = pssd.muids[len(pssd.muids)-1] |
| 3937 | pssd.muids = pssd.muids[:len(pssd.muids)-1] |
| 3938 | t.sessions[s] = pssd |
| 3939 | if len(pssd.muids) == 0 { |
| 3940 | delete(t.sessions, s) |
| 3941 | return &pssd, true |
| 3942 | } |
| 3943 | |
| 3944 | return &pssd, false |
| 3945 | } |
| 3946 | } |
| 3947 | |
| 3948 | return nil, false |
| 3949 | } |
| 3950 | |
| 3951 | // Check if topic has any online (non-background) users. |
| 3952 | func (t *Topic) isOnline() bool { |
no test coverage detected