aboutsummaryrefslogtreecommitdiff
path: root/src/Channel.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-05-21 08:44:23 +0200
committerdec05eba <dec05eba@protonmail.com>2018-05-21 08:44:25 +0200
commit8f275fa7ec9bf14c06cb72edb00bc9a2469d0458 (patch)
tree1b6c87ba14f08ff0337131fb539200d605368d8a /src/Channel.cpp
parentf5aaf1b1cc94e28d4fa423a3d0b8ca286cf7f87d (diff)
Improve online/offline users (fade offline users, ping on channel init)
Diffstat (limited to 'src/Channel.cpp')
-rw-r--r--src/Channel.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Channel.cpp b/src/Channel.cpp
index 41233ad..5043665 100644
--- a/src/Channel.cpp
+++ b/src/Channel.cpp
@@ -52,7 +52,7 @@ namespace dchat
u64 pingTimestamp = unsignedDeserializer.extract<u64>();
// TODO: A malicious peer can capture the packets and reply them after the user has reconnect and counter has reset, need to fix this somehow.
// One solution is for the user to store the counter locally in file and continue using it when reconnecting
- if(pingCounter > user->pingCounter)
+ if(pingTimestamp > user->pingTimestamp)
{
user->pingCounter = pingCounter;
user->pingTimestamp = pingTimestamp;
@@ -64,6 +64,12 @@ namespace dchat
}
return result;
});
+
+ if(localUser->type == User::Type::ONLINE_LOCAL_USER)
+ {
+ auto onlineLocalUser = static_cast<OnlineLocalUser*>(localUser);
+ sendPing(onlineLocalUser->pingCounter + 1, database->getSyncedTimestampUtc().getCombined());
+ }
}
}