// NewReceiverFromCmd parses the info in the command func NewReceiverFromCmd( applicationID string, cmd *protocol.Cmd, sendChannel chan []byte, router router.Router, userID string) (rec *Receiver, err error) { messageStore, err := router.MessageStore() if err != nil { return nil, err } rec = &Receiver{ applicationID: applicationID, sendC: sendChannel, router: router, messageStore: messageStore, cancelC: make(chan bool, 1), enableNotifications: true, userID: userID, } if len(cmd.Arg) == 0 || cmd.Arg[0] != '/' { return nil, fmt.Errorf("command requires at least a path argument, but non given") } args := strings.SplitN(cmd.Arg, " ", 3) rec.path = protocol.Path(args[0]) if len(args) > 1 { rec.doFetch = true rec.startID, err = strconv.ParseInt(args[1], 10, 64) if err != nil { return nil, fmt.Errorf("startid has to be empty or int, but was %q: %v", args[1], err) } } rec.doSubscription = true if len(args) > 2 { rec.doSubscription = false rec.maxCount, err = strconv.Atoi(args[2]) if err != nil { return nil, fmt.Errorf("maxCount has to be empty or int, but was %q: %v", args[1], err) } } return rec, nil }