-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathsubscription.cpp
39 lines (31 loc) · 1.05 KB
/
subscription.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#include "subscription.h"
/**
* @brief Subscription::operator == Compares subscription equality based on client id only.
* @param rhs Right-hand side.
* @return true or false
*
* QoS is not used in the comparision. This means you upgrade your QoS by subscribing again. The
* specs don't specify what to do there.
*/
bool Subscription::operator==(const Subscription &rhs) const
{
if (session.expired() && rhs.session.expired())
return true;
if (session.expired() || rhs.session.expired())
return false;
const std::shared_ptr<Session> lhs_ses = session.lock();
const std::shared_ptr<Session> rhs_ses = rhs.session.lock();
return lhs_ses && rhs_ses && lhs_ses->getClientId() == rhs_ses->getClientId();
}
void Subscription::reset()
{
session.reset();
qos = 0;
}