예제 #1
0
파일: server.py 프로젝트: jcsy521/ydws
 def handle_request(self, data):
     try:
         packet = T_CLWCheck(data)
         command = packet.head.command
         if command == GATEWAY.T_MESSAGE_TYPE.AGPS:
             head = packet.head
             body = packet.body 
             args = DotDict(success=GATEWAY.RESPONSE_STATUS.SUCCESS,
                            agps_data=None)
             ap = AgpsParser(body, head)
             agps_sign = self.get_agps_sign(ap.ret, int(head.timestamp))
             if agps_sign != int(head.agps_sign, 16):
                 args.success = GATEWAY.RESPONSE_STATUS.INVALID_SESSIONID
                 logging.error("[AGPS] agps_sign invalid.")
             else:
                 agps = ap.ret
                 args.agps_data = self.get_agps_from_redis(agps)
                 if args.agps_data:
                     ac = AgpsComposer(args)
                     return ac.buf
                 else:
                     logging.error("[AGPS] there's no invalid agps data.")
                     return None 
     except:
         logging.exception("[AGPS] Handle agps request exception.")
         return None