OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::qt::qml_websocket_outbound_socket::state Struct Reference

Inherits Nano::Observer.

Detailed Description

Owns the transport and every websocketpp-side callback.

The Nano::Observer lives here and not on the QObject on purpose: the signals it listens to belong to client, a member of this very object, so the unsynchronized slot lists can only be mutated while the whole state is being destroyed, at which point no handler can still be running. The QObject, destroyed on the Qt thread while the websocketpp thread may be firing, is only ever reached under qt_mutex.

Public Member Functions

void detach ()
 
void fire_open ()
 Nano slots, always on the websocketpp thread.
 
void fire_fail ()
 
void fire_close ()
 
void fire_message (websocketpp::frame::opcode::value opcode, std::string msg)
 Message delivery, always on the websocketpp thread.
 

Public Attributes

std::string url
 
std::unique_ptr< ossia::net::websocket_clientclient
 
std::atomic_bool alive {true}
 
std::atomic_bool closed {false}
 
std::mutex qt_mutex
 
qml_websocket_outbound_socket * self {}
 

Member Data Documentation

◆ closed

std::atomic_bool ossia::qt::qml_websocket_outbound_socket::state::closed {false}

The script's onClose is reported at most once, be it a peer-initiated close or an explicit one.

◆ qt_mutex

std::mutex ossia::qt::qml_websocket_outbound_socket::state::qt_mutex

Guards self, which is cleared before the QObject starts dying. Held for the whole asio -> Qt handover.