Collaboration diagram for MultiClient:

The C++ does not have a specific Client class for connecting to multiple servers. This is because the task can be easily accomplished with classes already contained in the STL. The following example shows how this can be done. After the initial setup and adding the clients to the list, the for_each loop needs to be called each time a multi-read is performed.

#include <libplayerc++/playerc++.h>
#include <iostream>
#include <list>
#include <algorithm>

int main(int argc, char** argv)
    using namespace PlayerCc;
    // Let's subscribe to a couple of different clients, and
    // set up a proxy or two.
    PlayerClient client1("feyd");
    CameraProxy  cp1(&client1);

    PlayerClient client2("rabban");
    CameraProxy  cp2(&client2);

    // We can now create a list of pointers to PlayerClient,
    // and add two elements
    std::list<PlayerClient*> m_client;

    while (1)
      // this will now iterate through the list of clients and read from
      // all of them that have data waiting

      // output the proxies just for fun
      std::cout << cp1 << std::endl;
      std::cout << cp2 << std::endl;

  catch (PlayerCc::PlayerError e)
    std::cerr << e << std::endl;
    return -1;
  return 1;

Last updated 12 September 2005 21:38:45