| 70 | } |
| 71 | |
| 72 | void on_message(const std::shared_ptr<vsomeip::message>& _response) { |
| 73 | std::stringstream its_message; |
| 74 | its_message << "Received a notification for Event [" << std::hex << std::setfill('0') << std::setw(4) << _response->get_service() |
| 75 | << "." << std::setw(4) << _response->get_instance() << "." << std::setw(4) << _response->get_method() |
| 76 | << "] to Client/Session [" << std::setw(4) << _response->get_client() << "/" << std::setw(4) << _response->get_session() |
| 77 | << "] = "; |
| 78 | std::shared_ptr<vsomeip::payload> its_payload = _response->get_payload(); |
| 79 | its_message << "(" << std::dec << its_payload->get_length() << ") " << std::hex; |
| 80 | for (uint32_t i = 0; i < its_payload->get_length(); ++i) |
| 81 | its_message << std::setw(2) << static_cast<int>(its_payload->get_data()[i]) << " "; |
| 82 | std::cout << its_message.str() << std::endl; |
| 83 | |
| 84 | if (_response->get_client() == 0) { |
| 85 | if ((its_payload->get_length() % 5) == 0) { |
| 86 | std::shared_ptr<vsomeip::message> its_get = vsomeip::runtime::get()->create_request(); |
| 87 | its_get->set_service(SAMPLE_SERVICE_ID); |
| 88 | its_get->set_instance(SAMPLE_INSTANCE_ID); |
| 89 | its_get->set_method(SAMPLE_GET_METHOD_ID); |
| 90 | its_get->set_reliable(use_tcp_); |
| 91 | app_->send(its_get); |
| 92 | } |
| 93 | |
| 94 | if ((its_payload->get_length() % 8) == 0) { |
| 95 | std::shared_ptr<vsomeip::message> its_set = vsomeip::runtime::get()->create_request(); |
| 96 | its_set->set_service(SAMPLE_SERVICE_ID); |
| 97 | its_set->set_instance(SAMPLE_INSTANCE_ID); |
| 98 | its_set->set_method(SAMPLE_SET_METHOD_ID); |
| 99 | its_set->set_reliable(use_tcp_); |
| 100 | |
| 101 | const vsomeip::byte_t its_data[] = {0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x50, 0x51, 0x52}; |
| 102 | std::shared_ptr<vsomeip::payload> its_set_payload = vsomeip::runtime::get()->create_payload(); |
| 103 | its_set_payload->set_data(its_data, sizeof(its_data)); |
| 104 | its_set->set_payload(its_set_payload); |
| 105 | app_->send(its_set); |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | private: |
| 111 | std::shared_ptr<vsomeip::application> app_; |
nothing calls this directly
no test coverage detected