Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Yershov <syershov@maps.me>2016-12-14 17:41:41 +0300
committerSergey Yershov <syershov@maps.me>2016-12-14 17:41:41 +0300
commitee087914bb9426825635d8ef7d8bf5feebc80a79 (patch)
tree461ffdcc7aa6778600d6b04720f99ed0079465a5 /tracking
parentc290c9ee9ee9a0368d35fecc5ef30f63d7c4554b (diff)
Disable sending point in background
Diffstat (limited to 'tracking')
-rw-r--r--tracking/connection.cpp8
-rw-r--r--tracking/connection.hpp1
-rw-r--r--tracking/reporter.cpp10
-rw-r--r--tracking/reporter.hpp3
4 files changed, 22 insertions, 0 deletions
diff --git a/tracking/connection.cpp b/tracking/connection.cpp
index 1042457e60..15e6750041 100644
--- a/tracking/connection.cpp
+++ b/tracking/connection.cpp
@@ -46,6 +46,14 @@ bool Connection::Reconnect()
return true;
}
+void Connection::Shutdown()
+{
+ if (!m_socket)
+ return;
+
+ m_socket->Close();
+}
+
// TODO: implement historical
bool Connection::Send(boost::circular_buffer<DataPoint> const & points)
{
diff --git a/tracking/connection.hpp b/tracking/connection.hpp
index c72578cdbf..1ff04cc121 100644
--- a/tracking/connection.hpp
+++ b/tracking/connection.hpp
@@ -24,6 +24,7 @@ public:
Connection(unique_ptr<platform::Socket> socket, string const & host, uint16_t port,
bool isHistorical);
bool Reconnect();
+ void Shutdown();
bool Send(boost::circular_buffer<DataPoint> const & points);
private:
diff --git a/tracking/reporter.cpp b/tracking/reporter.cpp
index 5050002065..48f7174988 100644
--- a/tracking/reporter.cpp
+++ b/tracking/reporter.cpp
@@ -92,6 +92,16 @@ void Reporter::Run()
bool Reporter::SendPoints()
{
+ if (!m_allowSendingPoints)
+ {
+ if (m_wasConnected)
+ {
+ m_realtimeSender.Shutdown();
+ m_wasConnected = false;
+ }
+ return true;
+ }
+
if (m_points.empty())
return true;
diff --git a/tracking/reporter.hpp b/tracking/reporter.hpp
index 380a3cd460..c013bc021a 100644
--- a/tracking/reporter.hpp
+++ b/tracking/reporter.hpp
@@ -37,12 +37,15 @@ public:
void AddLocation(location::GpsInfo const & info);
+ void SetAllowSendingPoints(bool allow) { m_allowSendingPoints = allow; }
+
inline void SetIdleFunc(function<void()> fn) { m_idleFn = fn; }
private:
void Run();
bool SendPoints();
+ bool m_allowSendingPoints = true;
Connection m_realtimeSender;
milliseconds m_pushDelay;
bool m_wasConnected = false;