func mainEasyTest() { c := conf.TestConf() dcr, err := rest.DeviceCmdPoll(c.URL, c.DeviceID, c.AccessKey, nil, nil, nil) if err != nil { say.Infof("Error: %s", err.Error()) } else { say.Infof("Ok: %+v", dcr) } }
func mainInfinityLoop() { c := conf.TestConf() control := rest.NewPollAsync() out := make(chan rest.DeviceCmdResource, 16) go rest.DeviceCmdPollAsync(c.URL, c.DeviceID, c.AccessKey, out, control) for { select { case item := <-out: say.Infof("item: %+v", item) } } }
func mainInfinityLoopWithInterruption() { c := conf.TestConf() control := rest.NewPollAsync() out := make(chan rest.DeviceCmdResource, 16) go rest.DeviceCmdPollAsync(c.URL, c.DeviceID, c.AccessKey, out, control) for { select { case item := <-out: say.Infof("item: %+v", item) case <-time.After(15 * time.Second): say.Infof("start Stop()") control.Stop() say.Infof("finish Stop()") return } } }