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

Method unregisterSession

server/topic.go:308–337  ·  view source on GitHub ↗

unregisterSession implements all logic following receipt of a leave request via the Topic.unreg channel.

(msg *ClientComMessage)

Source from the content-addressed store, hash-verified

306// unregisterSession implements all logic following receipt of a leave
307// request via the Topic.unreg channel.
308func (t *Topic) unregisterSession(msg *ClientComMessage) {
309 if t.currentCall != nil {
310 shouldTerminateCall := false
311 if msg.sess.isMultiplex() {
312 // Check if any of the call party sessions is multiplexed over msg.sess.
313 for _, p := range t.currentCall.parties {
314 if p.sess.isProxy() && p.sess.multi == msg.sess {
315 shouldTerminateCall = true
316 break
317 }
318 }
319 } else if _, found := t.currentCall.parties[msg.sess.sid]; found {
320 // Normal session disconnecting from topic. Just terminate the call.
321 shouldTerminateCall = true
322 }
323 if shouldTerminateCall {
324 t.terminateCallInProgress(false)
325 }
326 }
327 t.handleLeaveRequest(msg, msg.sess)
328 if msg.init && msg.sess.inflightReqs != nil {
329 // If it's a client initiated request.
330 msg.sess.inflightReqs.Done()
331 }
332
333 // If there are no more subscriptions to this topic, start a kill timer
334 if len(t.sessions) == 0 && t.cat != types.TopicCatSys {
335 t.killTimer.Reset(idleMasterTopicTimeout)
336 }
337}
338
339// registerSession handles a session join (registration) request
340// received via the Topic.reg channel.

Calls 6

handleLeaveRequestMethod · 0.95
isMultiplexMethod · 0.80
isProxyMethod · 0.80
DoneMethod · 0.80
ResetMethod · 0.45