Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
d2f1f81c
Commit
d2f1f81c
authored
Jan 7, 2019
by
Sébastien Blin
Browse files
Options
Downloads
Patches
Plain Diff
ringaccount: remove presence only if all values for all devices has expired
Change-Id: I4dda17d658aaa5324827625cef4971499119ec84
parent
e2ac73b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ringdht/ringaccount.cpp
+11
-12
11 additions, 12 deletions
src/ringdht/ringaccount.cpp
with
11 additions
and
12 deletions
src/ringdht/ringaccount.cpp
+
11
−
12
View file @
d2f1f81c
...
@@ -125,8 +125,8 @@ struct RingAccount::BuddyInfo
...
@@ -125,8 +125,8 @@ struct RingAccount::BuddyInfo
/* the buddy id */
/* the buddy id */
dht
::
InfoHash
id
;
dht
::
InfoHash
id
;
/*
the presence timestamps
*/
/*
number of devices connected on the DHT
*/
std
::
set
<
dht
::
InfoHash
>
devices
;
uint32_t
devices
_cnt
{}
;
/* The disposable object to update buddy info */
/* The disposable object to update buddy info */
std
::
future
<
size_t
>
listenToken
;
std
::
future
<
size_t
>
listenToken
;
...
@@ -1988,20 +1988,19 @@ RingAccount::trackPresence(const dht::InfoHash& h, BuddyInfo& buddy)
...
@@ -1988,20 +1988,19 @@ RingAccount::trackPresence(const dht::InfoHash& h, BuddyInfo& buddy)
if
(
not
dht_
.
isRunning
())
{
if
(
not
dht_
.
isRunning
())
{
return
;
return
;
}
}
buddy
.
listenToken
=
dht_
.
listen
<
DeviceAnnouncement
>
(
h
,
[
this
,
h
](
DeviceAnnouncement
&&
dev
,
bool
expired
){
buddy
.
listenToken
=
dht_
.
listen
<
DeviceAnnouncement
>
(
h
,
[
this
,
h
](
DeviceAnnouncement
&&
,
bool
expired
){
bool
wasConnected
,
isConnected
;
bool
wasConnected
,
isConnected
;
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
buddyInfoMtx
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
buddyInfoMtx
);
auto
buddy
=
trackedBuddies_
.
find
(
h
);
auto
buddy
=
trackedBuddies_
.
find
(
h
);
if
(
buddy
==
trackedBuddies_
.
end
())
if
(
buddy
==
trackedBuddies_
.
end
())
return
true
;
return
true
;
wasConnected
=
not
buddy
->
second
.
devices
.
empty
();
wasConnected
=
buddy
->
second
.
devices_cnt
>
0
;
if
(
expired
)
{
if
(
expired
)
buddy
->
second
.
devices
.
erase
(
dev
.
dev
);
--
buddy
->
second
.
devices_cnt
;
}
else
{
else
buddy
->
second
.
devices
.
emplace
(
dev
.
dev
);
++
buddy
->
second
.
devices_cnt
;
}
isConnected
=
buddy
->
second
.
devices_cnt
>
0
;
isConnected
=
not
buddy
->
second
.
devices
.
empty
();
}
}
if
(
isConnected
and
not
wasConnected
)
{
if
(
isConnected
and
not
wasConnected
)
{
onTrackedBuddyOnline
(
h
);
onTrackedBuddyOnline
(
h
);
...
@@ -2019,7 +2018,7 @@ RingAccount::getTrackedBuddyPresence()
...
@@ -2019,7 +2018,7 @@ RingAccount::getTrackedBuddyPresence()
std
::
lock_guard
<
std
::
mutex
>
lock
(
buddyInfoMtx
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
buddyInfoMtx
);
std
::
map
<
std
::
string
,
bool
>
presence_info
;
std
::
map
<
std
::
string
,
bool
>
presence_info
;
for
(
const
auto
&
buddy_info_p
:
trackedBuddies_
)
for
(
const
auto
&
buddy_info_p
:
trackedBuddies_
)
presence_info
.
emplace
(
buddy_info_p
.
first
.
toString
(),
not
buddy_info_p
.
second
.
devices
.
empty
()
);
presence_info
.
emplace
(
buddy_info_p
.
first
.
toString
(),
buddy_info_p
.
second
.
devices
_cnt
>
0
);
return
presence_info
;
return
presence_info
;
}
}
...
@@ -2290,7 +2289,7 @@ RingAccount::doRegister_()
...
@@ -2290,7 +2289,7 @@ RingAccount::doRegister_()
dhtPeerConnector_
->
onDhtConnected
(
ringDeviceId_
);
dhtPeerConnector_
->
onDhtConnected
(
ringDeviceId_
);
for
(
auto
&
buddy
:
trackedBuddies_
)
{
for
(
auto
&
buddy
:
trackedBuddies_
)
{
buddy
.
second
.
devices
.
clear
()
;
buddy
.
second
.
devices
_cnt
=
0
;
trackPresence
(
buddy
.
first
,
buddy
.
second
);
trackPresence
(
buddy
.
first
,
buddy
.
second
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment