Broadcast a transient message to active topic subscribers. Not reporting any errors.
(msg *ClientComMessage)
| 1250 | // Broadcast a transient message to active topic subscribers. |
| 1251 | // Not reporting any errors. |
| 1252 | func (s *Session) note(msg *ClientComMessage) { |
| 1253 | if s.ver == 0 || msg.AsUser == "" { |
| 1254 | // Silently ignore the message: have not received {hi} or don't know who sent the message. |
| 1255 | return |
| 1256 | } |
| 1257 | |
| 1258 | // Expand topic name and validate request. |
| 1259 | var resp *ServerComMessage |
| 1260 | msg.RcptTo, resp = s.expandTopicName(msg) |
| 1261 | if resp != nil { |
| 1262 | // Silently ignoring the message |
| 1263 | return |
| 1264 | } |
| 1265 | |
| 1266 | switch msg.Note.What { |
| 1267 | case "data": |
| 1268 | if msg.Note.Payload == nil { |
| 1269 | // Payload must be present in 'data' notifications. |
| 1270 | return |
| 1271 | } |
| 1272 | case "kp", "kpa", "kpv": |
| 1273 | if msg.Note.SeqId != 0 { |
| 1274 | return |
| 1275 | } |
| 1276 | case "call": |
| 1277 | if types.GetTopicCat(msg.RcptTo) != types.TopicCatP2P { |
| 1278 | // Calls are only available in P2P topics. |
| 1279 | return |
| 1280 | } |
| 1281 | fallthrough |
| 1282 | case "read", "recv": |
| 1283 | if msg.Note.SeqId <= 0 { |
| 1284 | return |
| 1285 | } |
| 1286 | default: |
| 1287 | return |
| 1288 | } |
| 1289 | |
| 1290 | if sub := s.getSub(msg.RcptTo); sub != nil { |
| 1291 | // Pings can be sent to subscribed topics only |
| 1292 | select { |
| 1293 | case sub.broadcast <- msg: |
| 1294 | default: |
| 1295 | // Reply with a 503 to the user. |
| 1296 | s.queueOut(ErrServiceUnavailableReply(msg, msg.Timestamp)) |
| 1297 | logs.Err.Println("s.note: sub.broacast channel full, topic ", msg.RcptTo, s.sid) |
| 1298 | } |
| 1299 | } else if msg.Note.What == "recv" || (msg.Note.What == "call" && (msg.Note.Event == "ringing" || msg.Note.Event == "hang-up" || msg.Note.Event == "accept")) { |
| 1300 | // One of the following events happened: |
| 1301 | // 1. Client received a pres notification about a new message, initiated a fetch |
| 1302 | // from the server (and detached from the topic) and acknowledges receipt. |
| 1303 | // 2. Client is either accepting or terminating the current video call or |
| 1304 | // letting the initiator of the call know that it is ringing/notifying |
| 1305 | // the user about the call. |
| 1306 | // |
| 1307 | // Hub will forward to topic, if appropriate. |
| 1308 | select { |
| 1309 | case globals.hub.routeCli <- msg: |
nothing calls this directly
no test coverage detected