# -*- coding: GBK -*- # ÔÚÏ߻ظ´AI # author: Alee # Date: 2011.9.1 # history: 2011.9.1 Created from AI.AIBase import * from Protocol.PacketsSend import tagCOnlineReturn import logging import time #ÔÚÏ߻ظ´¼ä¸ô(Second) OnlineReplyPeriod = 15 class AIOnlineReply(AIBase): #ËùÓÐAI±ØÐë²ÉÓÃÕâÖй̶¨µÄ³õʼ»¯Ô­ÐÍ£¬ÒÔ±ãAIMgr×Ô¶¯¼ÓÔØ def __init__(self, robot ): AIBase.__init__(self, robot, OnlineReplyPeriod, True, True ) self.lastTime = 0 def _Process( self ): if time.time() - self.lastTime < OnlineReplyPeriod: return # Çå³ýûÓÐÐÄÌø°üµÄ»úÆ÷ÈË logging.info("ΣÏÕ³¬¹ý15ÃëûÓд¦ÀíÐÄÌø°ü-%s"%self.robot.GetPlayerInfo().GetAccID()) #self.robot.SetNeedDestroy(True) #from Robot import RobotMgr #RobotMgr.GetRobotMgr().DisconnectServer(self.robot) pass def _RegisterPacket(self, aiMgr): #//01 13 ·þÎñÆ÷ÐÄÌø°ü#tagServerHeart aiMgr.RegNetMsg(0x0113, self.OnHeart, False) #//01 11 ÔÚÏß»ØÓ¦»Ø±¨#tagOnlineReply #aiMgr.RegNetMsg(0x0111, self.OnHeartReply, False) def OnHeart(self, pack): nowTime = time.time() onlineR = tagCOnlineReturn() self.robot.Send( onlineR ) self.lastTime = time.time() #print "------»Ø¸´0113ÐÄÌø°ü" def OnHeartReply(self, pack): print "--------------------------ÏìÓ¦ÐÄÌø"