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

Method addSub

server/session.go:179–194  ·  view source on GitHub ↗
(topic string, sub *Subscription)

Source from the content-addressed store, hash-verified

177}
178
179func (s *Session) addSub(topic string, sub *Subscription) {
180 if s.multi != nil {
181 s.multi.addSub(topic, sub)
182 return
183 }
184 s.subsLock.Lock()
185
186 // Sessions that serve as an interface between proxy topics and their masters (proxy sessions)
187 // may have only one subscription, that is, to its master topic.
188 // Normal sessions may be subscribed to multiple topics.
189
190 if !s.isMultiplex() || s.countSub() == 0 {
191 s.subs[topic] = sub
192 }
193 s.subsLock.Unlock()
194}
195
196func (s *Session) getSub(topic string) *Subscription {
197 // Don't check s.multi here. Let it panic if called for proxy session.

Callers 2

proxyMasterResponseMethod · 0.80
subscriptionReplyMethod · 0.80

Calls 4

isMultiplexMethod · 0.95
countSubMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected