| 1 |
package ami_test |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"fmt" |
| 6 |
"github.com/wenerme/astgo/ami" |
| 7 |
) |
| 8 |
|
| 9 |
func ExampleConnect() { |
| 10 |
boot := make(chan *ami.Message, 1) |
| 11 |
|
| 12 |
conn, err := ami.Connect( |
| 13 |
"192.168.1.1:5038", |
| 14 |
ami.WithAuth("admin", "admin"), |
| 15 |
|
| 16 |
ami.WithSubscribe(ami.SubscribeFullyBootedChanOnce(boot)), |
| 17 |
ami.WithSubscribe(func(ctx context.Context, msg *ami.Message) bool { |
| 18 |
fmt.Println(msg.Format()) |
| 19 |
return true |
| 20 |
}, ami.SubscribeSend(), |
| 21 |
)) |
| 22 |
if err != nil { |
| 23 |
panic(err) |
| 24 |
} |
| 25 |
<-boot |
| 26 |
|
| 27 |
_ = conn |
| 28 |
} |