Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

daninmadison
Copy link
Contributor

@daninmadison daninmadison commented Jun 5, 2024

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.

  • If it is unable to connect and the last know state was connected, it updates its last know state to disconnected. If the options Buffered channel is set, it will send a False (disconnected) message on the buffered channel.
  • If it is able to connect to the Asterisk websocket and read messages, and the known state was disconnected, it changes it to connected. If the options Buffered channel is set, it will send a True (connected) message on the buffered channel.

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

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.
Then, it should pass this value in the clients Options fields.
When the Client connects for the web socket, it knows it's last known state.
If it is unable to connect and the last know state was connected, it updates it's last know state to disconnected. If the options Buffered channel is set, it will send a False (disconnected) message on the buffered channel.
If it is able to connect the websocket and read messages, if the last known state was disconnected, it changes it to connected. If the options Buffered channel is set, it will send a True (connected) message on the buffered channel.
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 want 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants