OSSIA
Open Scenario System for Interactive Application
ossia::net::protocol_base Class Referenceabstract

The protocol_base class. More...

Inheritance diagram for ossia::net::protocol_base:
ossia::net::multiplex_protocol ossia::oscquery::oscquery_server_protocol ossia::oscquery_asio::oscquery_server_protocol

Detailed Description

The protocol_base class.

A protocol is used to implement remote communication.

See also
local_protocol
osc_protocol
minuit_protocol
oscquery_protocol
midi_protocol

Public Types

enum  flags { SupportsMultiplex = (1 << 0) }
 

Public Member Functions

 protocol_base (flags f)
 
 protocol_base (const protocol_base &)=delete
 
 protocol_base (protocol_base &&)=delete
 
protocol_baseoperator= (const protocol_base &)=delete
 
protocol_baseoperator= (protocol_base &&)=delete
 
virtual bool pull (parameter_base &)=0
 Pulls a value from the server synchronously. More...
 
virtual std::future< void > pull_async (parameter_base &)
 Pulls a value from the server asynchronously. More...
 
virtual void request (parameter_base &)
 Request an update on a value.
 
virtual bool push (const parameter_base &, const ossia::value &v)=0
 Send a value to the network.
 
virtual bool push (const parameter_base &, ossia::value &&v)
 
bool push (const parameter_base &p)
 
virtual bool echo_incoming_message (const message_origin_identifier &, const parameter_base &, const ossia::value &v)
 called when some protocol on the same device received a message. More...
 
virtual bool push_bundle (const std::vector< const ossia::net::parameter_base * > &)
 Send many values in one go if the protocol supports it.
 
virtual bool push_bundle (tcb::span< ossia::bundle_element >)
 
virtual bool push_bundle_bounded (tcb::span< ossia::bundle_element >)
 
virtual bool push_raw (const full_parameter_data &)=0
 Send a value to the network.
 
virtual bool push_raw_bundle (const std::vector< full_parameter_data > &)
 Send a value to the network.
 
virtual bool observe (parameter_base &, bool)=0
 Notify the network that a parameter should be listened to. More...
 
virtual bool publish (const parameter_base &)
 Notify the network that a parameter is to be published. More...
 
virtual bool unpublish (const parameter_base &)
 Notify the network that a parameter is to be removed. More...
 
virtual bool observe_quietly (parameter_base &, bool)
 Begin observation without notifying the other computers.
 
virtual std::future< void > update_async (node_base &node_base)
 If the protocol supports it, request the namespace corresponding to this node.
 
virtual bool update (node_base &node_base)=0
 If the protocol supports it, request the namespace corresponding to this node. If the update takes too long, nodes may be dropped as there is a default timeout.
 
virtual void set_device (ossia::net::device_base &dev)
 It is mandatory to call this function from device implementations, when the protocol is set.
 
virtual void set_logger (const network_logger &l)
 Replace the loggers used.
 
virtual const network_loggerget_logger () const noexcept
 
virtual bool connected () const noexcept
 
virtual void connect ()
 
virtual void start_execution ()
 
virtual void stop_execution ()
 
virtual void stop ()
 
flags get_flags () const noexcept
 
bool test_flag (flags f) const noexcept
 

Public Attributes

Nano::Signal< void()> on_connection_open
 
Nano::Signal< void()> on_connection_closed
 
Nano::Signal< void()> on_connection_failure
 

Protected Attributes

const flags m_flags {}
 
network_logger m_logger
 

Member Function Documentation

◆ pull()

virtual bool ossia::net::protocol_base::pull ( parameter_base )
pure virtual

Pulls a value from the server synchronously.

Returns
True if the value was correctly retrieved.

Implemented in ossia::net::multiplex_protocol, ossia::oscquery_asio::oscquery_server_protocol, and ossia::oscquery::oscquery_server_protocol.

◆ pull_async()

std::future< void > ossia::net::protocol_base::pull_async ( parameter_base )
virtual

Pulls a value from the server asynchronously.

Returns
A future that will be set when the value is received.

Reimplemented in ossia::oscquery_asio::oscquery_server_protocol, and ossia::oscquery::oscquery_server_protocol.

◆ echo_incoming_message()

bool ossia::net::protocol_base::echo_incoming_message ( const message_origin_identifier &  ,
const parameter_base ,
const ossia::value v 
)
virtual

called when some protocol on the same device received a message.

This can be used to echo the message to other protocols on the same device.

Reimplemented in ossia::oscquery_asio::oscquery_server_protocol, ossia::oscquery::oscquery_server_protocol, and ossia::net::multiplex_protocol.

◆ observe()

virtual bool ossia::net::protocol_base::observe ( parameter_base ,
bool   
)
pure virtual

Notify the network that a parameter should be listened to.

In some protocols (Minuit, OSCQuery), this may send a message to the other client so that it regularly sends values of this parameter to the local computer.

If a parameter is listened to, when a message is received, parameter_base::setValue will be called, which will notify the local signals. Else, parameter_base::setValueQuiet will be called : the value will be updated but the signals won't be notified.

Implemented in ossia::net::multiplex_protocol, ossia::oscquery_asio::oscquery_server_protocol, and ossia::oscquery::oscquery_server_protocol.

◆ publish()

bool ossia::net::protocol_base::publish ( const parameter_base )
virtual

Notify the network that a parameter is to be published.

In some protocols (MQTT), this may send a message to the broker to indicate that a new topic is being made available for publication.

◆ unpublish()

bool ossia::net::protocol_base::unpublish ( const parameter_base )
virtual

Notify the network that a parameter is to be removed.

In some protocols (MQTT), this may send a message to the broker to indicate that a previously published topic is disappearing.