handleServerMsg is the top-level handler of messages generated at the server.
(msg *ServerComMessage)
| 631 | |
| 632 | // handleServerMsg is the top-level handler of messages generated at the server. |
| 633 | func (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 |
| 650 | func (t *Topic) handleSubscription(msg *ClientComMessage) error { |