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

Method handleServerMsg

server/topic.go:633–647  ·  view source on GitHub ↗

handleServerMsg is the top-level handler of messages generated at the server.

(msg *ServerComMessage)

Source from the content-addressed store, hash-verified

631
632// handleServerMsg is the top-level handler of messages generated at the server.
633func (t *Topic) handleServerMsg(msg *ServerComMessage) {
634 // Server-generated message: {info} or {pres}.
635 if t.isInactive() {
636 // Ignore message - the topic is paused or being deleted.
637 return
638 }
639 if msg.Pres != nil {
640 t.handlePresence(msg)
641 } else if msg.Info != nil {
642 t.broadcastToSessions(msg)
643 } else {
644 // TODO(gene): maybe remove this panic.
645 logs.Err.Panic("topic: wrong server message type for broadcasting", t.name)
646 }
647}
648
649// Session subscribed to a topic, created == true if topic was just created and {pres} needs to be announced
650func (t *Topic) handleSubscription(msg *ClientComMessage) error {

Callers 4

runLocalMethod · 0.95
NoChangeInStatusTestFunction · 0.80

Calls 3

isInactiveMethod · 0.95
handlePresenceMethod · 0.95
broadcastToSessionsMethod · 0.95

Tested by 3

NoChangeInStatusTestFunction · 0.64