func expectStatusMessage(t *testing.T, client *client.Client, name string, arg string) string { select { case notify := <-client.StatusMessages(): assert.Equal(t, name, notify.Name) assert.Equal(t, arg, notify.Arg) return notify.Json case <-time.After(time.Second * 1): t.Logf("no notification of type %s after 1 second", name) t.Fail() return "" } }
func readLoop(client *client.Client) { for { select { case incomingMessage := <-client.Messages(): if args.Verbose { fmt.Println(string(incomingMessage.Bytes())) } else { fmt.Printf("%v: %v\n", incomingMessage.PublisherUserId, incomingMessage.BodyAsString()) } case error := <-client.Errors(): fmt.Println("ERROR: " + string(error.Bytes())) case status := <-client.StatusMessages(): fmt.Println(string(status.Bytes())) fmt.Println() } } }
func readLoop(client client.Client) { for { select { case incomingMessage := <-client.Messages(): if *verbose { fmt.Println(string(incomingMessage.Bytes())) } else { fmt.Printf("%v: %v\n", incomingMessage.UserID, incomingMessage.BodyAsString()) } case e := <-client.Errors(): fmt.Println("ERROR: " + string(e.Bytes())) case status := <-client.StatusMessages(): fmt.Println(string(status.Bytes())) fmt.Println() } } }