libivon 0.1.0
Voice-over-IP library
Loading...
Searching...
No Matches
ivon::ClientWrapper Class Reference

Consumer-facing C++ wrapper around the libivon C ABI. More...

#include <ivon_client_wrapper.hpp>

Inheritance diagram for ivon::ClientWrapper:
ivon::IClient

Classes

struct  Config
 Configuration for creating a client (mirrors ivon_client_config_t). More...
 
struct  NonOwning
 Tag type for constructing a non-owning wrapper around an existing handle. More...
 

Public Member Functions

 ClientWrapper (const Config &cfg)
 Construct a wrapper and create the underlying C client.
 
 ClientWrapper (ivon_client_t handle, NonOwning) noexcept
 Construct a non-owning wrapper around an existing handle.
 
 ~ClientWrapper () override
 
 ClientWrapper (const ClientWrapper &)=delete
 
ClientWrapperoperator= (const ClientWrapper &)=delete
 
 ClientWrapper (ClientWrapper &&)=delete
 
ClientWrapperoperator= (ClientWrapper &&)=delete
 
expected_void< NegotiationErrorconnect () override
 Connect to the server (blocking).
 
void disconnect () override
 Disconnect from the server (blocks until closed).
 
ConnectionState connection_state () const noexcept override
 Get the current connection lifecycle state.
 
bool is_connected () const noexcept override
 Check if fully connected to the server.
 
bool is_synchronized () const noexcept override
 Check if initial state synchronization is complete.
 
std::string session_id () const override
 Get the session ID assigned by the server (empty if not connected).
 
bool send_client_message (const std::string &client_id, const std::string &type, const std::vector< uint8_t > &buffer) override
 Send a typed message to a specific remote client. Returns false if not connected.
 
bool send_broadcast_message (const std::string &type, const std::vector< uint8_t > &buffer) override
 Broadcast a typed message to all connected clients. Returns false if not connected.
 
bool send_group_message (const std::string &group_id, const std::string &type, const std::vector< uint8_t > &buffer) override
 Send a typed message to all members of a group via TCP. Returns false if not connected or not a member.
 
size_t get_remote_client_count () const noexcept override
 Get the count of remote clients in the session.
 
bool has_remote_client (const std::string &client_id) const noexcept override
 Check if a remote client with the given ID exists.
 
std::vector< std::string > get_remote_client_ids () const override
 Get all remote client IDs as a vector.
 
bool join_group (const std::string &group_id) override
 Request to join a group. Returns false if not connected.
 
bool leave_group (const std::string &group_id) override
 Request to leave a group. Returns false if not connected.
 
bool request_group_list () override
 Request the list of available groups from the server.
 
bool set_mute (const std::string &group_id, const std::string &target_client_id, bool muted) override
 Mute or unmute a target client in a specific group.
 
bool is_group_member (const std::string &group_id) const override
 Check if this client is a member of the given group.
 
std::vector< std::string > get_group_ids () const override
 Get all group IDs this client is a member of.
 
bool send_group_data (const std::string &group_id, const unsigned char *data, size_t len) override
 Send raw data to a group via the fanout channel.
 
bool send_group_data (const std::string &group_id, const std::vector< uint8_t > &data) override
 Send raw data to a group via the fanout channel (vector overload).
 
bool set_fanout_sender_id (uint64_t sender_id) override
 Set this client's fanout sender ID (used for audio routing).
 
void on_tofu_verify (TofuVerifyCallback cb) override
 Set the TOFU key verification callback (called during negotiation).
 
void on_password_required (PasswordCallback cb) override
 Set the password prompt callback (called when the server requires auth).
 
void on_client_message (ClientMessageCallback cb) override
 Set the callback for incoming direct client messages.
 
void on_client_joined (ClientJoinedCallback cb) override
 Set the callback fired when a remote client joins the session.
 
void on_client_left (ClientLeftCallback cb) override
 Set the callback fired when a remote client leaves the session.
 
void on_kicked (KickedCallback cb) override
 Set the callback fired when this client is kicked from the server.
 
void on_disconnected (DisconnectedCallback cb) override
 Set the callback fired when the connection is lost or closed.
 
void on_connection_state_changed (ConnectionStateCallback cb) override
 Set the callback fired on connection state transitions.
 
void on_group_joined (GroupJoinCallback cb) override
 Set the callback for group join results.
 
void on_group_left (GroupLeaveCallback cb) override
 Set the callback for group leave results.
 
void on_group_key_update (GroupKeyUpdateCallback cb) override
 Set the callback fired when a group's encryption key is rotated.
 
void on_group_member_joined (GroupMemberJoinedCallback cb) override
 Set the callback fired when another client joins a group.
 
void on_group_member_left (GroupMemberLeftCallback cb) override
 Set the callback fired when another client leaves a group.
 
void on_group_kicked (GroupKickedCallback cb) override
 Set the callback fired when this client is kicked from a group.
 
void on_group_list (GroupListCallback cb) override
 Set the callback for group list responses.
 
void on_group_mute (GroupMuteCallback cb) override
 Set the callback for group mute operation results.
 
void on_fanout_data (FanoutDataCallback cb) override
 Set the callback for incoming fanout data.
 
void on_fanout_error (FanoutErrorCallback cb) override
 Set the callback for fanout channel errors.
 
void on_server_properties (ServerPropertiesCallback cb) override
 Set the callback for initial server properties received during sync.
 
void on_server_property_update (ServerPropertyUpdateCallback cb) override
 Set the callback for server property updates.
 
void on_group_property_update (GroupPropertyUpdateCallback cb) override
 Set the callback for group property updates.
 
ivon_client_t handle () const noexcept
 Get the underlying opaque C handle.
 
- Public Member Functions inherited from ivon::IClient
virtual ~IClient ()=default
 

Detailed Description

Consumer-facing C++ wrapper around the libivon C ABI.

RAII handle: the constructor creates the client, the destructor destroys it. Non-copyable, non-moveable; use std::unique_ptr for deferred initialization or ownership transfer.

All methods delegate to the corresponding ivon_client_* C function. String returns copy into std::string; list queries return std::vector<std::string>.

Constructor & Destructor Documentation

◆ ClientWrapper() [1/4]

ivon::ClientWrapper::ClientWrapper ( const Config cfg)
inlineexplicit

Construct a wrapper and create the underlying C client.

Exceptions
std::runtime_errorif creation fails.

◆ ClientWrapper() [2/4]

ivon::ClientWrapper::ClientWrapper ( ivon_client_t  handle,
NonOwning   
)
inlineexplicitnoexcept

Construct a non-owning wrapper around an existing handle.

◆ ~ClientWrapper()

ivon::ClientWrapper::~ClientWrapper ( )
inlineoverride

◆ ClientWrapper() [3/4]

ivon::ClientWrapper::ClientWrapper ( const ClientWrapper )
delete

◆ ClientWrapper() [4/4]

ivon::ClientWrapper::ClientWrapper ( ClientWrapper &&  )
delete

Member Function Documentation

◆ connect()

expected_void< NegotiationError > ivon::ClientWrapper::connect ( )
inlineoverridevirtual

Connect to the server (blocking).

Returns
Expected on success, or NegotiationError on failure.

Implements ivon::IClient.

◆ connection_state()

ConnectionState ivon::ClientWrapper::connection_state ( ) const
inlineoverridevirtualnoexcept

Get the current connection lifecycle state.

Implements ivon::IClient.

◆ disconnect()

void ivon::ClientWrapper::disconnect ( )
inlineoverridevirtual

Disconnect from the server (blocks until closed).

Implements ivon::IClient.

◆ get_group_ids()

std::vector< std::string > ivon::ClientWrapper::get_group_ids ( ) const
inlineoverridevirtual

Get all group IDs this client is a member of.

Implements ivon::IClient.

◆ get_remote_client_count()

size_t ivon::ClientWrapper::get_remote_client_count ( ) const
inlineoverridevirtualnoexcept

Get the count of remote clients in the session.

Implements ivon::IClient.

◆ get_remote_client_ids()

std::vector< std::string > ivon::ClientWrapper::get_remote_client_ids ( ) const
inlineoverridevirtual

Get all remote client IDs as a vector.

Implements ivon::IClient.

◆ handle()

ivon_client_t ivon::ClientWrapper::handle ( ) const
inlinenoexcept

Get the underlying opaque C handle.

◆ has_remote_client()

bool ivon::ClientWrapper::has_remote_client ( const std::string &  client_id) const
inlineoverridevirtualnoexcept

Check if a remote client with the given ID exists.

Implements ivon::IClient.

◆ is_connected()

bool ivon::ClientWrapper::is_connected ( ) const
inlineoverridevirtualnoexcept

Check if fully connected to the server.

Implements ivon::IClient.

◆ is_group_member()

bool ivon::ClientWrapper::is_group_member ( const std::string &  group_id) const
inlineoverridevirtual

Check if this client is a member of the given group.

Implements ivon::IClient.

◆ is_synchronized()

bool ivon::ClientWrapper::is_synchronized ( ) const
inlineoverridevirtualnoexcept

Check if initial state synchronization is complete.

Implements ivon::IClient.

◆ join_group()

bool ivon::ClientWrapper::join_group ( const std::string &  group_id)
inlineoverridevirtual

Request to join a group. Returns false if not connected.

Implements ivon::IClient.

◆ leave_group()

bool ivon::ClientWrapper::leave_group ( const std::string &  group_id)
inlineoverridevirtual

Request to leave a group. Returns false if not connected.

Implements ivon::IClient.

◆ on_client_joined()

void ivon::ClientWrapper::on_client_joined ( ClientJoinedCallback  cb)
inlineoverridevirtual

Set the callback fired when a remote client joins the session.

Implements ivon::IClient.

◆ on_client_left()

void ivon::ClientWrapper::on_client_left ( ClientLeftCallback  cb)
inlineoverridevirtual

Set the callback fired when a remote client leaves the session.

Implements ivon::IClient.

◆ on_client_message()

void ivon::ClientWrapper::on_client_message ( ClientMessageCallback  cb)
inlineoverridevirtual

Set the callback for incoming direct client messages.

Implements ivon::IClient.

◆ on_connection_state_changed()

void ivon::ClientWrapper::on_connection_state_changed ( ConnectionStateCallback  cb)
inlineoverridevirtual

Set the callback fired on connection state transitions.

Implements ivon::IClient.

◆ on_disconnected()

void ivon::ClientWrapper::on_disconnected ( DisconnectedCallback  cb)
inlineoverridevirtual

Set the callback fired when the connection is lost or closed.

Implements ivon::IClient.

◆ on_fanout_data()

void ivon::ClientWrapper::on_fanout_data ( FanoutDataCallback  cb)
inlineoverridevirtual

Set the callback for incoming fanout data.

Implements ivon::IClient.

◆ on_fanout_error()

void ivon::ClientWrapper::on_fanout_error ( FanoutErrorCallback  cb)
inlineoverridevirtual

Set the callback for fanout channel errors.

Implements ivon::IClient.

◆ on_group_joined()

void ivon::ClientWrapper::on_group_joined ( GroupJoinCallback  cb)
inlineoverridevirtual

Set the callback for group join results.

Implements ivon::IClient.

◆ on_group_key_update()

void ivon::ClientWrapper::on_group_key_update ( GroupKeyUpdateCallback  cb)
inlineoverridevirtual

Set the callback fired when a group's encryption key is rotated.

Implements ivon::IClient.

◆ on_group_kicked()

void ivon::ClientWrapper::on_group_kicked ( GroupKickedCallback  cb)
inlineoverridevirtual

Set the callback fired when this client is kicked from a group.

Implements ivon::IClient.

◆ on_group_left()

void ivon::ClientWrapper::on_group_left ( GroupLeaveCallback  cb)
inlineoverridevirtual

Set the callback for group leave results.

Implements ivon::IClient.

◆ on_group_list()

void ivon::ClientWrapper::on_group_list ( GroupListCallback  cb)
inlineoverridevirtual

Set the callback for group list responses.

Implements ivon::IClient.

◆ on_group_member_joined()

void ivon::ClientWrapper::on_group_member_joined ( GroupMemberJoinedCallback  cb)
inlineoverridevirtual

Set the callback fired when another client joins a group.

Implements ivon::IClient.

◆ on_group_member_left()

void ivon::ClientWrapper::on_group_member_left ( GroupMemberLeftCallback  cb)
inlineoverridevirtual

Set the callback fired when another client leaves a group.

Implements ivon::IClient.

◆ on_group_mute()

void ivon::ClientWrapper::on_group_mute ( GroupMuteCallback  cb)
inlineoverridevirtual

Set the callback for group mute operation results.

Implements ivon::IClient.

◆ on_group_property_update()

void ivon::ClientWrapper::on_group_property_update ( GroupPropertyUpdateCallback  cb)
inlineoverridevirtual

Set the callback for group property updates.

Implements ivon::IClient.

◆ on_kicked()

void ivon::ClientWrapper::on_kicked ( KickedCallback  cb)
inlineoverridevirtual

Set the callback fired when this client is kicked from the server.

Implements ivon::IClient.

◆ on_password_required()

void ivon::ClientWrapper::on_password_required ( PasswordCallback  cb)
inlineoverridevirtual

Set the password prompt callback (called when the server requires auth).

Implements ivon::IClient.

◆ on_server_properties()

void ivon::ClientWrapper::on_server_properties ( ServerPropertiesCallback  cb)
inlineoverridevirtual

Set the callback for initial server properties received during sync.

Implements ivon::IClient.

◆ on_server_property_update()

void ivon::ClientWrapper::on_server_property_update ( ServerPropertyUpdateCallback  cb)
inlineoverridevirtual

Set the callback for server property updates.

Implements ivon::IClient.

◆ on_tofu_verify()

void ivon::ClientWrapper::on_tofu_verify ( TofuVerifyCallback  cb)
inlineoverridevirtual

Set the TOFU key verification callback (called during negotiation).

Implements ivon::IClient.

◆ operator=() [1/2]

ClientWrapper & ivon::ClientWrapper::operator= ( ClientWrapper &&  )
delete

◆ operator=() [2/2]

ClientWrapper & ivon::ClientWrapper::operator= ( const ClientWrapper )
delete

◆ request_group_list()

bool ivon::ClientWrapper::request_group_list ( )
inlineoverridevirtual

Request the list of available groups from the server.

Implements ivon::IClient.

◆ send_broadcast_message()

bool ivon::ClientWrapper::send_broadcast_message ( const std::string &  type,
const std::vector< uint8_t > &  buffer 
)
inlineoverridevirtual

Broadcast a typed message to all connected clients. Returns false if not connected.

Implements ivon::IClient.

◆ send_client_message()

bool ivon::ClientWrapper::send_client_message ( const std::string &  client_id,
const std::string &  type,
const std::vector< uint8_t > &  buffer 
)
inlineoverridevirtual

Send a typed message to a specific remote client. Returns false if not connected.

Implements ivon::IClient.

◆ send_group_data() [1/2]

bool ivon::ClientWrapper::send_group_data ( const std::string &  group_id,
const std::vector< uint8_t > &  data 
)
inlineoverridevirtual

Send raw data to a group via the fanout channel (vector overload).

Implements ivon::IClient.

◆ send_group_data() [2/2]

bool ivon::ClientWrapper::send_group_data ( const std::string &  group_id,
const unsigned char *  data,
size_t  len 
)
inlineoverridevirtual

Send raw data to a group via the fanout channel.

Implements ivon::IClient.

◆ send_group_message()

bool ivon::ClientWrapper::send_group_message ( const std::string &  group_id,
const std::string &  type,
const std::vector< uint8_t > &  buffer 
)
inlineoverridevirtual

Send a typed message to all members of a group via TCP. Returns false if not connected or not a member.

Implements ivon::IClient.

◆ session_id()

std::string ivon::ClientWrapper::session_id ( ) const
inlineoverridevirtual

Get the session ID assigned by the server (empty if not connected).

Implements ivon::IClient.

◆ set_fanout_sender_id()

bool ivon::ClientWrapper::set_fanout_sender_id ( uint64_t  sender_id)
inlineoverridevirtual

Set this client's fanout sender ID (used for audio routing).

Implements ivon::IClient.

◆ set_mute()

bool ivon::ClientWrapper::set_mute ( const std::string &  group_id,
const std::string &  target_client_id,
bool  muted 
)
inlineoverridevirtual

Mute or unmute a target client in a specific group.

Implements ivon::IClient.


The documentation for this class was generated from the following file: