Skip to content

Commit

Permalink
feature: add registration for connection change events
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz-blasz committed Dec 2, 2024
1 parent 7e75ab4 commit aec2d2f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions languages/cpp/templates/sdk/include/firebolt.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,29 @@ struct IFireboltAccessor {
*/
virtual Firebolt::Error Connect ( OnConnectionChanged listener ) = 0;

/**
* @brief Register a callback for any changes in the connection to the endpoint. Only a single callback is supported.
*
* @param listener Connection status listener
*
* @return None
*/
virtual void RegisterConnectionChangeListener ( OnConnectionChanged listener ) = 0;

/**
* @brief Unregister previously registered callback.
*
* @return None
*/
virtual void UnregisterConnnectionChangeListener ( ) = 0;

/**
* @brief Returs whether there is a connection to the endpoint
*
* @return bool
*/
virtual bool IsConnected ( ) const = 0;

/**
* @brief Disconnects from the Websocket endpoint.
*
Expand Down
15 changes: 15 additions & 0 deletions languages/cpp/templates/sdk/src/firebolt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ namespace Firebolt {
return _accessor->Connect(listener);
}

void RegisterConnectionChangeListener( OnConnectionChanged listener ) override
{
return _accessor->RegisterConnectionChangeListener(listener);
}

void UnregisterConnnectionChangeListener() override
{
_accessor->UnregisterConnnectionChangeListener();
}

bool IsConnected() const override
{
return _accessor->IsConnected();
}

Firebolt::Error Disconnect() override
{
return _accessor->Disconnect();
Expand Down

0 comments on commit aec2d2f

Please sign in to comment.