diff options
author | Jürgen Gehring <juergen.gehring@bmw.de> | 2015-07-28 08:50:57 -0700 |
---|---|---|
committer | Jürgen Gehring <juergen.gehring@bmw.de> | 2015-07-28 08:50:57 -0700 |
commit | 336db577dc057b7a13aeaf8eb2c777a26a7b607a (patch) | |
tree | 014ba65d235fd73364cc9544b5e69bdd09f7301e /CommonAPI-Examples/E04PhoneBook/src | |
parent | 9b91fba4b4008007847f32630cbe160287f291fd (diff) | |
download | genivi-common-api-runtime-3.1.3.tar.gz |
CommonAPI-Tools 3.1.33.1.3
Diffstat (limited to 'CommonAPI-Examples/E04PhoneBook/src')
-rw-r--r-- | CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp | 18 | ||||
-rw-r--r-- | CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp | 4 |
2 files changed, 17 insertions, 5 deletions
diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp index d1b9d84..7db3313 100644 --- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp +++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookClient.cpp @@ -137,31 +137,41 @@ int main() { const std::string &domain = "local"; const std::string &instance = "commonapi.examples.PhoneBook"; + const std::string &connection = "client-sample"; - std::shared_ptr < E04PhoneBookProxy<> > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance); + std::shared_ptr < E04PhoneBookProxy<> > myProxyA = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, connection); while (!myProxyA->isAvailable()) { usleep(10); } + std::cout << "Service for Proxy A is available!" << std::endl; - const CommonAPI::ConnectionId_t otherConnectionId = "42"; - - std::shared_ptr < E04PhoneBookProxy<> > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnectionId); + const CommonAPI::ConnectionId_t otherConnection = "other-client-sample"; + std::shared_ptr < E04PhoneBookProxy<> > myProxyB = runtime->buildProxy < E04PhoneBookProxy > (domain, instance, otherConnection); while (!myProxyB->isAvailable()) { usleep(10); } + std::cout << "Service for Proxy B is available!" << std::endl; // Subscribe A to broadcast myProxyA->getPhoneBookDataSetSelectiveEvent().subscribe( [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) { + std::cout << "-- A --" << std::endl; printFilterResult(phoneBookDataSet, "A"); + std::cout << "-------" << std::endl; }); + std::cout << "Subscribed A" << std::endl; + // Subscribe B to broadcast myProxyB->getPhoneBookDataSetSelectiveEvent().subscribe( [&](const std::vector<E04PhoneBook::phoneBookDataElementMap>& phoneBookDataSet) { + std::cout << "-- B --" << std::endl; printFilterResult(phoneBookDataSet, "B"); + std::cout << "-------" << std::endl; }); + std::cout << "Subscribed B" << std::endl; + // Get actual phoneBook from service CommonAPI::CallStatus myCallStatus; std::vector<E04PhoneBook::phoneBookStruct> myValue; diff --git a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp index bece39c..020209b 100644 --- a/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp +++ b/CommonAPI-Examples/E04PhoneBook/src/E04PhoneBookService.cpp @@ -19,10 +19,12 @@ int main() { const std::string &domain = "local"; const std::string &instance = "commonapi.examples.PhoneBook"; + const std::string &connection = "service-sample"; + std::shared_ptr<E04PhoneBookStubImpl> myService = std::make_shared<E04PhoneBookStubImpl>(); myService->setPhoneBookAttribute(myService->createTestPhoneBook()); - bool successfullyRegistered = runtime->registerService(domain, instance, myService); + bool successfullyRegistered = runtime->registerService(domain, instance, myService, connection); while (!successfullyRegistered) { std::cout << "Register Service failed, trying again in 100 milliseconds..." << std::endl; |