summaryrefslogtreecommitdiff
path: root/examples/subscribe-sample.cpp
diff options
context:
space:
mode:
authorJürgen Gehring <Juergen.Gehring@bmw.de>2016-09-20 03:59:53 -0700
committerJürgen Gehring <Juergen.Gehring@bmw.de>2016-09-20 03:59:53 -0700
commit273814c76be4a8f906dc053492529b8d53b9e807 (patch)
treee7160dc68fe3f478a0c5c86aaccaeb620d528b63 /examples/subscribe-sample.cpp
parent4c5d160362d8693aed8abd642212e68c9778bbda (diff)
downloadvSomeIP-273814c76be4a8f906dc053492529b8d53b9e807.tar.gz
vSomeIP 2.2.42.2.4
Diffstat (limited to 'examples/subscribe-sample.cpp')
-rw-r--r--examples/subscribe-sample.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/subscribe-sample.cpp b/examples/subscribe-sample.cpp
index 9a03722..915ea11 100644
--- a/examples/subscribe-sample.cpp
+++ b/examples/subscribe-sample.cpp
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2015 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
+// Copyright (C) 2014-2016 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -29,6 +29,10 @@ public:
<< "]"
<< std::endl;
+ app_->register_state_handler(
+ std::bind(&client_sample::on_state, this,
+ std::placeholders::_1));
+
app_->register_message_handler(
vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD,
std::bind(&client_sample::on_message, this,
@@ -53,6 +57,12 @@ public:
app_->start();
}
+ void on_state(vsomeip::state_type_e _state) {
+ if (_state == vsomeip::state_type_e::ST_REGISTERED) {
+ app_->request_service(SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID);
+ }
+ }
+
void on_availability(vsomeip::service_t _service, vsomeip::instance_t _instance, bool _is_available) {
std::cout << "Service ["
<< std::setw(4) << std::setfill('0') << std::hex << _service << "." << _instance