Move ping code

This commit is contained in:
angelblue05 2016-10-13 23:02:40 -05:00
parent 124b3bdde1
commit e2bbf61866

View file

@ -120,6 +120,14 @@ class Service(object):
# If an item is playing # If an item is playing
if self.kodi_player.isPlaying(): if self.kodi_player.isPlaying():
# ping metrics server to keep sessions alive while playing
# ping every 5 min
timeSinceLastPing = time.time() - self.lastMetricPing
if(timeSinceLastPing > 300):
self.lastMetricPing = time.time()
ga = GoogleAnalytics()
ga.sendEventData("PlayAction", "PlayPing")
self._report_progress() self._report_progress()
elif not self.startup: elif not self.startup:
@ -139,15 +147,6 @@ class Service(object):
# Wait until Emby server is online # Wait until Emby server is online
# or Kodi is shut down. # or Kodi is shut down.
self._server_online_check() self._server_online_check()
# ping metrics server to keep sessions alive while playing
# ping every 5 min
timeSinceLastPing = time.time() - self.lastMetricPing
if(timeSinceLastPing > 300):
self.lastMetricPing = time.time()
if self.kodi_player.isPlaying():
ga = GoogleAnalytics()
ga.sendEventData("PlayAction", "PlayPing")
if self.monitor.waitForAbort(1): if self.monitor.waitForAbort(1):
# Abort was requested while waiting. We should exit # Abort was requested while waiting. We should exit