-static int make_subscription_unsubscription(struct afb_req request,
- std::shared_ptr<low_can_subscription_t>& can_subscription,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s,
- bool subscribe)
-{
- /* Make the subscription or unsubscription to the event */
- if (((subscribe ? afb_req_subscribe : afb_req_unsubscribe)(request, s[can_subscription->get_index()]->get_event())) < 0)
- {
- AFB_ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str());
- return -1;
- }
- return 0;
-}
-
-static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subscription,
- std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
-{
- int sub_index = can_subscription->get_index();
- can_subscription->set_event(afb_daemon_make_event(can_subscription->get_name().c_str()));
- s[sub_index] = can_subscription;
- if (!afb_event_is_valid(s[sub_index]->get_event()))
- {
- AFB_ERROR("Can't create an event for %s, something goes wrong.", can_subscription->get_name().c_str());
- return -1;
- }
- return 0;
-}
-
-/// @brief Will determine if it is needed or not to create the event handle and checks it to be sure that
-/// we got a valid afb_event to get subscribe or unsubscribe. Then launch the subscription or unsubscription