| # -*- 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 = 30  | 
|   | 
| class AIOnlineReply(AIBase):  | 
|     #ËùÓÐAI±ØÐë²ÉÓÃÕâÖй̶¨µÄ³õʼ»¯ÔÐÍ£¬ÒÔ±ãAIMgr×Ô¶¯¼ÓÔØ  | 
|     def __init__(self, robot ):  | 
|         AIBase.__init__(self, robot, OnlineReplyPeriod, True, True )  | 
|         self.lastTime = 0  | 
|     def _Process( self ):  | 
|         return  | 
|         #=======================================================================  | 
|         # if time.time() - self.lastTime < OnlineReplyPeriod:  | 
|         #    return  | 
|         #   | 
|         # # Çå³ýûÓÐÐÄÌø°üµÄ»úÆ÷ÈË  | 
|         # logging.info("clear no heart robot")  | 
|         # self.robot.SetIsLoginOK(False)  | 
|         # 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):  | 
|         onlineR = tagCOnlineReturn()  | 
|         self.robot.Send( onlineR )  | 
|         self.lastTime = time.time()  | 
|         #print "------»Ø¸´0113ÐÄÌø°ü"  | 
|           | 
|           | 
|     def OnHeartReply(self, pack):  | 
|         print "--------------------------ÏìÓ¦ÐÄÌø" |