CyCoreSystems / ari

Golang Asterisk REST Interface (ARI) library
Apache License 2.0
191 stars 73 forks source link

Added support for an optional connection up/down buffered channel to the client. #174

Open daninmadison opened 5 months ago

daninmadison commented 5 months ago

If the caller wants to be notified every time the client detects a change in the Connected/Disconnected state for the websocket (from the last known state), it should create a buffered channel of boolean, specifying the depth for the buffered channel. It can then pass this value in the clients Options fields. When the Client connects for the web socket, it knows its last known connected/disconnected state.

The caller (running on a different goroutine), is responsible for retrieving any messages from the buffered channel. (Only set it if you will retrieve these messages).

When the caller Closes the client, the client will cleanup and set it's Options buffered channel reference to nil. (This lets the garbage collector know the client is no longer using it). The caller should wait for the Close to complete. It is up to the caller to decide if it wants to read any buffered channel messages after calling Close.

The idea behind this is many telephony applications need to know when they can communicate/control calls with Asterisk. If the connection is down, an application can change it's internal state machine to know it can't communicate with Asterisk. This allows them to notify someone of a problem. Potentially switch to a different Asterisk for call control. Many more possibilities.

Additionally, added 3 more fields to the BridgeData (CreationTime, VideoMode, and VideoSourceID).


This change is Reviewable