Flip Reference

MulticastServiceExplorer Class Reference

Declared in

flip/contrib/MulticastServiceExplorer.h

class MulticastServiceExplorer;

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

MulticastServiceExplorer is used to automatically discover over Flip services running on the Local Area Network. It uses UDP multicast to achieve it.

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

Member Functions Synopsys

Constructor

Constructs the MulticastServiceExplorer

Destructor

Destructs the MulticastServiceExplorer

set_update_period

Sets the refresh period

process

Processes exploration

begin

Returns an iterator to the first session

end

Returns an iterator to the end

Member Functions

Constructor

MulticastServiceExplorer ();                                                              (1)
MulticastServiceExplorer (uint32_t multicast_ip, uint16_t port_min, uint16_t port_max);   (2)
  1. Convenience default constructor (see below).
  2. Constructor (see below).

Version 2 of the constructor takes the multicast ip and a range of port to explore on.

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

MulticastServiceExplorer explorer;
bool loop_flag = true;
// busy wait until we have at least one session discovered
while (loop_flag)
{
   explorer.process ();
   loop_flag = explorer.begin () == explorer.end ();
}
// look up the available sessions
for (auto && session : explorer)
{
   session.ip;       // IP of Flip server on the network
   session.port;     // Port of Flip server
   session.version;  // Version of Flip server
   session.metadata; // Map of arbitrary metadatas associated to the session
}

Destructor

~MulticastServiceExplorer ();

Destructor.


set_update_period

void  set_update_period (double period_s);

Set the refresh period for the explorer. By default this value is set to 2 seconds.

MulticastServiceExplorer explorer (0xefeefe89, 59150, 59169);
// very short update rate for unit tests
explorer.set_update_period (0.1);
explorer.process ();
[...]

process

void  process ();

Processes exploration. This function needs to be called regularly to let MulticastServiceExplorer do exploration. This function can be called often, as it only processes sockets when needed.


begin

const_iterator begin ();

Returns an iterator to the first session.


end

const_iterator end ();

Returns an iterator to the end.