EGD: Delay the first check-in long enough to prevent false 0-player counts.

This commit is contained in:
Greg Taylor 2016-04-04 22:13:51 -07:00
parent d1f5e7fdeb
commit db988b242b

View file

@ -1,12 +1,16 @@
from twisted.application.service import Service
from twisted.internet import reactor
from twisted.internet.task import LoopingCall
from twisted.application.service import Service
from evennia.contrib.gamedir_client.client import EvenniaGameDirClient
from evennia.utils import logger
# How many seconds to wait before triggering the first EGD check-in.
_FIRST_UPDATE_DELAY = 10
# How often to sync to the server
_CLIENT_UPDATE_RATE = 60 * 30
class EvenniaGameDirService(Service):
"""
Twisted Service that contains a LoopingCall for sending details on a
@ -22,7 +26,11 @@ class EvenniaGameDirService(Service):
def startService(self):
super(EvenniaGameDirService, self).startService()
# TODO: Check to make sure that the client is configured.
self.loop.start(_CLIENT_UPDATE_RATE)
# Start the loop, but only after a short delay. This allows the
# portal and the server time to sync up as far as total player counts.
# Prevents always reporting a count of 0.
reactor.callLater(
_FIRST_UPDATE_DELAY, self.loop.start, _CLIENT_UPDATE_RATE)
def stopService(self):
if self.running == 0: