diff --git a/evennia/contrib/gamedir_client/service.py b/evennia/contrib/gamedir_client/service.py index 16692606c8..36c6d2a306 100644 --- a/evennia/contrib/gamedir_client/service.py +++ b/evennia/contrib/gamedir_client/service.py @@ -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: