(msg *ClientComMessage)
| 1192 | } |
| 1193 | |
| 1194 | func (s *Session) del(msg *ClientComMessage) { |
| 1195 | msg.MetaWhat = parseMsgClientDel(msg.Del.What) |
| 1196 | |
| 1197 | // Delete user |
| 1198 | if msg.MetaWhat == constMsgDelUser { |
| 1199 | replyDelUser(s, msg) |
| 1200 | return |
| 1201 | } |
| 1202 | |
| 1203 | // Delete something other than user: topic, subscription, message(s) |
| 1204 | |
| 1205 | // Expand topic name and validate request. |
| 1206 | var resp *ServerComMessage |
| 1207 | msg.RcptTo, resp = s.expandTopicName(msg) |
| 1208 | if resp != nil { |
| 1209 | s.queueOut(resp) |
| 1210 | return |
| 1211 | } |
| 1212 | |
| 1213 | if msg.MetaWhat == 0 { |
| 1214 | s.queueOut(ErrMalformedReply(msg, msg.Timestamp)) |
| 1215 | logs.Warn.Println("s.del: invalid Del action", msg.Del.What, s.sid) |
| 1216 | return |
| 1217 | } |
| 1218 | |
| 1219 | if msg.MetaWhat == constMsgDelTopic { |
| 1220 | // Deleting topic: for sessions attached or not attached, send request to hub first. |
| 1221 | // Hub will forward to topic, if appropriate. |
| 1222 | select { |
| 1223 | case globals.hub.unreg <- &topicUnreg{ |
| 1224 | rcptTo: msg.RcptTo, |
| 1225 | pkt: msg, |
| 1226 | sess: s, |
| 1227 | del: true, |
| 1228 | }: |
| 1229 | default: |
| 1230 | // Reply with a 503 to the user. |
| 1231 | s.queueOut(ErrServiceUnavailableReply(msg, msg.Timestamp)) |
| 1232 | logs.Err.Println("s.del: hub.unreg channel full", s.sid) |
| 1233 | } |
| 1234 | } else if sub := s.getSub(msg.RcptTo); sub != nil { |
| 1235 | // Session is attached, deleting subscription or messages. Send to topic. |
| 1236 | select { |
| 1237 | case sub.meta <- msg: |
| 1238 | default: |
| 1239 | // Reply with a 503 to the user. |
| 1240 | s.queueOut(ErrServiceUnavailableReply(msg, msg.Timestamp)) |
| 1241 | logs.Err.Println("s.del: sub.meta channel full, topic ", msg.RcptTo, s.sid) |
| 1242 | } |
| 1243 | } else { |
| 1244 | // Must join the topic to delete messages or subscriptions. |
| 1245 | s.queueOut(ErrAttachFirst(msg, msg.Timestamp)) |
| 1246 | logs.Warn.Println("s.del: invalid Del action while unsubbed", msg.Del.What, s.sid) |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | // Broadcast a transient message to active topic subscribers. |
| 1251 | // Not reporting any errors. |
nothing calls this directly
no test coverage detected