replySetSub is a response to new subscription request or an update to a subscription {set.sub}: update topic metadata cache, save/update subs, reply to the caller as {ctrl} message, generate an invite
(h *Hub, sess *Session, set *MsgClientSet)
| 874 | // replySetSub is a response to new subscription request or an update to a subscription {set.sub}: |
| 875 | // update topic metadata cache, save/update subs, reply to the caller as {ctrl} message, generate an invite |
| 876 | func (t *Topic) replySetSub(h *Hub, sess *Session, set *MsgClientSet) error { |
| 877 | now := time.Now().UTC().Round(time.Millisecond) |
| 878 | |
| 879 | var uid types.Uid |
| 880 | if uid = types.ParseUserId(set.Sub.User); uid.IsZero() && set.Sub.User != "" { |
| 881 | // Invalid user ID |
| 882 | simpleByteSender(sess.send, ErrMalformed(set.Id, set.Topic, now)) |
| 883 | return errors.New("invalid user id") |
| 884 | } |
| 885 | |
| 886 | // if set.User is not set, request is for the current user |
| 887 | if !uid.IsZero() { |
| 888 | uid = sess.uid |
| 889 | } |
| 890 | |
| 891 | if uid == sess.uid { |
| 892 | return t.requestSub(h, sess, set.Id, set.Sub.Mode, set.Sub.Info, nil) |
| 893 | } else { |
| 894 | return t.approveSub(h, sess, uid, set) |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | // replyGetData is a response to a get.data request - load a list of stored messages, send them to session as {data} |
| 899 | // response goes to a single session rather than all sessions in a topic |
nothing calls this directly
no test coverage detected