| 29 | sender_(std::bind(&client_sample::run, this)) { } |
| 30 | |
| 31 | bool init() { |
| 32 | if (!app_->init()) { |
| 33 | std::cerr << "Couldn't initialize application" << std::endl; |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | std::cout << "Client settings [protocol=" << (use_tcp_ ? "TCP" : "UDP") << ":quiet=" << (be_quiet_ ? "true" : "false") |
| 38 | << ":cycle=" << cycle_ << "]" << std::endl; |
| 39 | |
| 40 | app_->register_state_handler(std::bind(&client_sample::on_state, this, std::placeholders::_1)); |
| 41 | |
| 42 | app_->register_message_handler(vsomeip::ANY_SERVICE, SAMPLE_INSTANCE_ID, vsomeip::ANY_METHOD, |
| 43 | std::bind(&client_sample::on_message, this, std::placeholders::_1)); |
| 44 | |
| 45 | request_->set_service(SAMPLE_SERVICE_ID); |
| 46 | request_->set_instance(SAMPLE_INSTANCE_ID); |
| 47 | request_->set_method(SAMPLE_METHOD_ID); |
| 48 | |
| 49 | std::shared_ptr<vsomeip::payload> its_payload = vsomeip::runtime::get()->create_payload(); |
| 50 | std::vector<vsomeip::byte_t> its_payload_data; |
| 51 | for (std::size_t i = 0; i < 10; ++i) |
| 52 | its_payload_data.push_back(vsomeip::byte_t(i % 256)); |
| 53 | its_payload->set_data(its_payload_data); |
| 54 | request_->set_payload(its_payload); |
| 55 | |
| 56 | app_->register_availability_handler( |
| 57 | SAMPLE_SERVICE_ID, SAMPLE_INSTANCE_ID, |
| 58 | std::bind(&client_sample::on_availability, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 59 | |
| 60 | app_->register_availability_handler( |
| 61 | SAMPLE_SERVICE_ID + 1, SAMPLE_INSTANCE_ID, |
| 62 | std::bind(&client_sample::on_availability, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); |
| 63 | return true; |
| 64 | } |
| 65 | |
| 66 | void start() { app_->start(); } |
| 67 |
no test coverage detected