diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ad9f0d84..298c0875 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,4 +1,5 @@ 0perl <444065+0perl@users.noreply.github.com> +Dan Cropp Danil Matyukhin JAF Laurel Lawson diff --git a/bridge.go b/bridge.go index 6ce61352..8a0f2778 100644 --- a/bridge.go +++ b/bridge.go @@ -66,13 +66,16 @@ type BridgeData struct { // Key is the cluster-unique identifier for this bridge Key *Key `json:"key"` - ID string `json:"id"` // Unique Id for this bridge - Class string `json:"bridge_class"` // Class of the bridge - Type string `json:"bridge_type"` // Type of bridge (mixing, holding, dtmf_events, proxy_media) - ChannelIDs []string `json:"channels"` // List of pariticipating channel ids - Creator string `json:"creator"` // Creating entity of the bridge - Name string `json:"name"` // The name of the bridge - Technology string `json:"technology"` // Name of the bridging technology + ID string `json:"id"` // Unique Id for this bridge + Class string `json:"bridge_class"` // Class of the bridge + Type string `json:"bridge_type"` // Type of bridge (mixing, holding, dtmf_events, proxy_media) + ChannelIDs []string `json:"channels"` // List of pariticipating channel ids + Creator string `json:"creator"` // Creating entity of the bridge + Name string `json:"name"` // The name of the bridge + Technology string `json:"technology"` // Name of the bridging technology + CreationTime string `json:"creationtime"` // Creation Time + VideoMode string `json:"video_mode"` // Video mode the bridge is using. (none, talker, sfu, single) + VideoSourceID string `json:"video_source_id"` // The ID of the channel that is the source of video in this bridge, if one exists. } // BridgeAddChannelOptions describes additional options to be applied to a channel when it is joined to a bridge diff --git a/client/native/client.go b/client/native/client.go index 166f3a36..dba933d8 100644 --- a/client/native/client.go +++ b/client/native/client.go @@ -49,6 +49,9 @@ type Options struct { // Logger provides a logger which should be used for this client. Logger *slog.Logger + + // buffered channel for sending Connection Up (true) or Down (false) messages to the caller + ChanMsgConnected chan bool } // ConnectWithContext creates and connects a new Client to Asterisk ARI. @@ -191,7 +194,14 @@ func (c *Client) Close() { c.cancel() } - c.connected = false + if c.connected { + c.connected = false + if c.Options.ChanMsgConnected != nil { + c.Options.ChanMsgConnected <- false + } + } + + c.Options.ChanMsgConnected = nil } // Application returns the ARI Application accessors for this client @@ -375,6 +385,9 @@ func (c *Client) listen(ctx context.Context, wg *sync.WaitGroup) { // We are connected c.connected = true + if c.Options.ChanMsgConnected != nil { + c.Options.ChanMsgConnected <- true + } // Signal that we are connected (the first time only) if wg != nil { @@ -387,13 +400,23 @@ func (c *Client) listen(ctx context.Context, wg *sync.WaitGroup) { case err = <-c.wsRead(ws): c.Options.Logger.Error("read failure on websocket", "error", err) - c.connected = false + if c.connected { + c.connected = false + if c.Options.ChanMsgConnected != nil { + c.Options.ChanMsgConnected <- false + } + } time.Sleep(10 * time.Millisecond) } // Make sure our websocket connection is closed before looping - c.connected = false + if c.connected { + c.connected = false + if c.Options.ChanMsgConnected != nil { + c.Options.ChanMsgConnected <- false + } + } err = ws.Close() if err != nil {