Poodletooth-iLand/otp/ai/TimeManagerAI.py

24 lines
993 B
Python
Raw Normal View History

2015-03-03 22:10:12 +00:00
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.DistributedObjectAI import DistributedObjectAI
from direct.distributed.ClockDelta import globalClockDelta
import time
class TimeManagerAI(DistributedObjectAI):
notify = DirectNotifyGlobal.directNotify.newCategory("TimeManagerAI")
def __init__(self, air):
DistributedObjectAI.__init__(self, air)
self.avId2DcReason = {}
2015-03-03 22:10:12 +00:00
def requestServerTime(self, context):
self.sendUpdateToAvatarId(self.air.getAvatarIdFromSender(), 'serverTime', [context, globalClockDelta.getRealNetworkTime(bits=32), int(time.time())])
2015-03-03 22:10:12 +00:00
def setDisconnectReason(self, reason):
self.avId2DcReason[self.air.getAvatarIdFromSender()] = reason
2015-03-03 22:10:12 +00:00
def setExceptionInfo(self, exception):
avId = self.air.getAvatarIdFromSender()
self.air.writeServerEvent('client-exception', avId, exception)
def getDisconnectReason(self, avId):
return self.avId2DcReason.get(avId, 0)