@@ -484,32 +484,24 @@ bool Countly::updateSession() {
484484 auto duration = std::chrono::duration_cast<std::chrono::seconds>(getSessionDuration ());
485485 mutex.lock ();
486486
487- if (no_events) {
488- if (duration.count () > COUNTLY_KEEPALIVE_INTERVAL) {
489- std::map<std::string, std::string> data = {
490- {" app_key" , session_params[" app_key" ].get <std::string>()},
491- {" device_id" , session_params[" device_id" ].get <std::string>()},
492- {" session_duration" , std::to_string (duration.count ())}
493- };
494- if (!sendHTTP (" /i" , Countly::serializeForm (data)).success ) {
495- mutex.unlock ();
496- return false ;
497- }
487+ if (!no_events) {
488+ std::map<std::string, std::string> data = {
489+ {" app_key" , session_params[" app_key" ].get <std::string>()},
490+ {" device_id" , session_params[" device_id" ].get <std::string>()},
491+ {" events" , events.dump ()}
492+ };
498493
499- last_sent += duration;
494+ if (!sendHTTP (" /i" , Countly::serializeForm (data)).success ) {
495+ mutex.unlock ();
496+ return false ;
500497 }
501-
502- mutex.unlock ();
503- return true ;
504498 }
505499
506500 std::map<std::string, std::string> data = {
507- {" app_key" , session_params[" app_key" ].get <std::string>()},
508- {" device_id" , session_params[" device_id" ].get <std::string>()},
509- {" session_duration" , std::to_string (duration.count ())},
510- {" events" , events.dump ()}
501+ {" app_key" , session_params[" app_key" ].get <std::string>()},
502+ {" device_id" , session_params[" device_id" ].get <std::string>()},
503+ {" session_duration" , std::to_string (duration.count ())}
511504 };
512-
513505 if (!sendHTTP (" /i" , Countly::serializeForm (data)).success ) {
514506 mutex.unlock ();
515507 return false ;
@@ -827,8 +819,8 @@ void Countly::updateLoop() {
827819 }
828820 size_t last_wait_milliseconds = wait_milliseconds;
829821 mutex.unlock ();
830- updateSession ();
831822 std::this_thread::sleep_for (std::chrono::milliseconds (last_wait_milliseconds));
823+ updateSession ();
832824 }
833825 mutex.lock ();
834826 running = false ;
0 commit comments