Flip Reference

MulticastServiceProvider Class Reference

Declared in

flip/contrib/MulticastServiceProvider.h

class MulticastServiceProvider;

Note: Classes part of contrib/ are not supported on every platform.

MulticastServiceProvider is used to automatically provide Flip services running on the Local Area Network. It uses UDP multicast to achieve it.

It is used in conjunction with MulticastServiceExplorer, see flip::MulticastServiceExplorer

Member Functions Synopsys

Constructor

Constructs the MulticastServiceProvider

Destructor

Destructs the MulticastServiceProvider

process

Processes service providing

Member Functions

Constructor

MulticastServiceProvider (uint16_t session_port, DocumentBase & document, std::map <std::string, std::string> metadata);                                                               (1)
MulticastServiceProvider (uint32_t multicast_ip, uint16_t port_min, uint16_t port_max, uint16_t session_port, DocumentBase & document, std::map <std::string, std::string> metadata);  (2)
  1. Convenience default constructor (see below).
  2. Constructor (see below).

Version 2 of the constructor takes the multicast ip and a range of possible port to provide the service on. The range allows to find an available port in the case where ports are already used for multicast.

It also provides the session_port which is the port on which the Flip document server is listening for new connections.

DocumentBase provides the model version to make sure that they are identical when connecting, and finally metada is arbitrary map of key values to provide more informational data to the service explorer.

Version 1 of the constructor uses default values as given by the class MulticastService.

// Setup a server for session number 1234567890123
DocumentValidatorVoid validator;
DocumentServer document_server (Model::use (), validator, 1234567890123ULL);
// Setup a socket listening on TCP port 9090 to accept new connections.
PortTransportServerTcp port (document_server, 9090);
std::map <std::string, std::string> metadata;
metadata ["name"] = "My great session!";
metadata ["date"] = "2015/05/06";
MulticastServiceProvider provider (9090, document_server, metadata);
for (;;)
{
   // process incoming connections and transfers
   port.process ();
   // process provider
   provider.process ();
}

Destructor

~MulticastServiceProvider ();

Destructor.


process

void  process ();

Processes service providing. This function needs to be called regularly to let MulticastServiceProvider provide service. This function can be called often, as it only processes sockets when needed.