session := avatarsdkgo.NewAvatarSession(
avatarsdkgo.WithAPIKey(...),
avatarsdkgo.WithConsoleEndpointURL(...),
avatarsdkgo.WithIngressEndpointURL(...),
avatarsdkgo.WithAvatarID(...),
avatarsdkgo.WithExpireAt(...),
avatarsdkgo.WithTransportFrames(func(data []byte, last bool) {
// transport frame, and end indicator
}),
avatarsdkgo.WithOnError(func(err error) {
// handle session error
}),
avatarsdkgo.WithOnClose(func() {
// handle session close
}),
)
if err := session.Init(ctx); err != nil {
// handle init error
}
connectionID, err := session.Start(ctx)
if err != nil {
// handle start error
}
defer func() {
if closeErr := session.Close(); closeErr != nil {
// handle close error
}
}()