Assign per-session fnd.Public. Returns true if value has been changed.
(sess *Session, public any)
| 3816 | |
| 3817 | // Assign per-session fnd.Public. Returns true if value has been changed. |
| 3818 | func (t *Topic) fndSetPublic(sess *Session, public any) bool { |
| 3819 | if t.cat != types.TopicCatFnd { |
| 3820 | panic("Not Fnd topic") |
| 3821 | } |
| 3822 | |
| 3823 | var pubmap map[string]any |
| 3824 | var ok bool |
| 3825 | if t.public != nil { |
| 3826 | if pubmap, ok = t.public.(map[string]any); !ok { |
| 3827 | // This could only happen if fnd.public is assigned outside of this function. |
| 3828 | panic("Invalid Fnd.Public type") |
| 3829 | } |
| 3830 | } |
| 3831 | if pubmap == nil { |
| 3832 | pubmap = make(map[string]any) |
| 3833 | } |
| 3834 | |
| 3835 | if public != nil { |
| 3836 | pubmap[sess.sid] = public |
| 3837 | } else { |
| 3838 | ok = (pubmap[sess.sid] != nil) |
| 3839 | delete(pubmap, sess.sid) |
| 3840 | if len(pubmap) == 0 { |
| 3841 | pubmap = nil |
| 3842 | } |
| 3843 | } |
| 3844 | t.public = pubmap |
| 3845 | return ok |
| 3846 | } |
| 3847 | |
| 3848 | // Remove per-session value of fnd.Public. |
| 3849 | func (t *Topic) fndRemovePublic(sess *Session) { |