MCPcopy Create free account
hub / github.com/COVESA/vsomeip / update_remote_subscription

Method update_remote_subscription

implementation/routing/src/eventgroupinfo.cpp:225–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225bool eventgroupinfo::update_remote_subscription(const std::shared_ptr<remote_subscription>& _subscription,
226 const std::chrono::steady_clock::time_point& _expiration, std::set<client_t>& _changed,
227 remote_subscription_id_t& _id, const bool _is_subscribe) {
228
229 bool its_result(false);
230
231 if (_subscription == nullptr) {
232 VSOMEIP_ERROR_P << "Received ptr is null";
233 return its_result;
234 }
235
236 std::shared_ptr<endpoint_definition> its_subscriber;
237 std::set<std::shared_ptr<event>> its_events;
238
239 {
240 std::scoped_lock its_lock(subscriptions_mutex_);
241
242 for (const auto& its_item : subscriptions_) {
243 if (its_item.second->equals(_subscription)) {
244 // update existing subscription
245 _changed = its_item.second->update(_subscription->get_clients(), _expiration, _is_subscribe);
246 _id = its_item.second->get_id();
247
248 // Copy acknowledgment states from existing subscription
249 for (const auto its_client : _subscription->get_clients()) {
250 auto its_state = its_item.second->get_client_state(its_client);
251 if (_is_subscribe && its_state == remote_subscription_state_e::SUBSCRIPTION_UNKNOWN) {
252 // We met the current subscription object during its
253 // unsubscribe process. Therefore, trigger a resubscription.
254 its_state = remote_subscription_state_e::SUBSCRIPTION_PENDING;
255 _changed.insert(its_client);
256 }
257
258 _subscription->set_client_state(its_client, its_state);
259 }
260
261 if (_is_subscribe) {
262 if (!_changed.empty()) {
263 // New clients:
264 // Let this be a child subscription
265 _subscription->set_parent(its_item.second);
266 update_id();
267 _subscription->set_id(id_);
268 subscriptions_[id_] = _subscription;
269 } else {
270 if (!_subscription->is_pending()) {
271 // Ensure parent has sent the initial events
272 if (!_subscription->force_initial_events() && !its_item.second->is_initial()) {
273 _subscription->set_initial(false);
274 }
275 } else {
276 its_item.second->set_answers(its_item.second->get_answers() + 1);
277 _subscription->set_parent(its_item.second);
278 _subscription->set_answers(0);
279 }
280 }
281 } else {
282 if (its_item.second->is_pending()) {

Callers 5

on_remote_subscribeMethod · 0.45
on_remote_unsubscribeMethod · 0.45
on_subscribe_ackMethod · 0.45
on_subscribe_nackMethod · 0.45
expire_subscriptionsMethod · 0.45

Calls 15

get_client_stateMethod · 0.80
insertMethod · 0.80
set_client_stateMethod · 0.80
set_parentMethod · 0.80
force_initial_eventsMethod · 0.80
set_answersMethod · 0.80
get_answersMethod · 0.80
remove_pendingMethod · 0.80
equalsMethod · 0.45
updateMethod · 0.45
get_clientsMethod · 0.45
get_idMethod · 0.45

Tested by

no test coverage detected