in example/main.go [36:77]
func main() {
flag.Parse()
ctx := context.Background()
client.DebugLogging = true
opts := []option.ClientOption{}
if *endpoint != "" {
opts = append(opts, option.WithEndpoint(*endpoint))
}
acsClient, err := client.NewClient(ctx, false, opts...)
if err != nil {
log.Fatal(err)
}
conn, err := client.NewConnection(ctx, *channel, acsClient)
if err != nil {
log.Fatal(err)
}
go func() {
for {
msg, err := conn.Receive()
if err != nil {
log.Println(err)
return
}
log.Printf("Got message: %+v", msg)
}
}()
if err := conn.SendMessage(&acpb.MessageBody{Body: &anypb.Any{Value: []byte("hello world")}}); err != nil {
log.Fatal(err)
}
time.Sleep(5 * time.Second)
if err := conn.SendMessage(&acpb.MessageBody{Body: &anypb.Any{Value: []byte("hello world")}}); err != nil {
log.Fatal(err)
}
time.Sleep(60 * time.Second)
conn.Close()
time.Sleep(1 * time.Second)
}