Esempio n. 1
0
    def get(self):
        try:
            imei = self.get_argument("imei")

        except Exception as e:
            self.write("arg error ")
            return
        type = self.get_argument("type", "1")
        command_num = self.get_argument("command_num", "005")
        logger.info("imei:%s, type:%s command_num:%s", imei, type, command_num)
        broadcastor = self.settings["broadcastor"]
        if type == "0":
            command_pk = TEST_S2C_COMMAND_DATA.get(command_num, None)
            #print "command_pk", command_pk
            if command_pk is None:
                self.write("arg error ")
                return
            else:
                pk = terminal_packets.SendCommandReq(imei, command_pk)
        else:
            pk = terminal_packets.GetLocationAck(terminal_proto.GenSN(), imei)
        send_data = str(pk)
        ret = yield broadcastor.send_msg_multicast((imei, ), send_data)
        ret_str = "send ok" if ret else "send fail"
        self._OnOpLog("s2c send_data:%s ret:%s" % (send_data, ret_str), imei)
        self.write(ret_str)
Esempio n. 2
0
 def do_request(self):
     terminal_rpc = self.settings["terminal_rpc"]
     terminal_imei_dao = self.settings["terminal_imei_dao"]
     res = {"status": error_codes.EC_SUCCESS}
     try:
         imei = self.get_argument("imei")
     except Exception as e:
         res["status"] = error_codes.EC_INVALID_ARGS
     else:
         pk = terminal_packets.GetLocationAck(terminal_proto.GenSN(), imei)
         send_data = str(pk)
         ok = True
         try:
             server_id = yield self.call_func(terminal_imei_dao,
                                              "get_server_id", imei)
             ret = yield terminal_rpc.unicast(server_id,
                                              imei=imei,
                                              content=send_data)
             res["status"] = ret["status"]
             if res["status"] != error_codes.EC_SUCCESS:
                 ok = False
         except Exception, e:
             status = error_codes.EC_SYS_ERROR
             res["status"] = status
             logger.exception(e)
             ok = False
         ret_str = "send ok" if ok else "send fail"
         self.on_log(
             "[broadcast_srv_d] s2c send_data:%s ret:%s" %
             (send_data, ret_str), imei)
Esempio n. 3
0
 def get(self):
     terminal_rpc = self.settings["terminal_rpc"]
     terminal_imei_dao = self.settings["terminal_imei_dao"]
     try:
         imei = self.get_argument("imei")
     except Exception as e:
         self.write("arg error ")
         return
     type = self.get_argument("type", "1")
     command_num = self.get_argument("command_num", "005")
     logger.info("imei:%s, type:%s command_num:%s", imei, type, command_num)
     if type == "0":
         command_pk = TEST_S2C_COMMAND_DATA.get(command_num, None)
         if command_pk is None:
             self.write("arg error ")
             return
         else:
             pk = terminal_packets.SendCommandReq(imei, command_pk)
     else:
         pk = terminal_packets.GetLocationAck(terminal_proto.GenSN(), imei)
     send_data = str(pk)
     ok = True
     try:
         server_id = yield self.call_func(terminal_imei_dao,
                                          "get_server_id", imei)
         ret = yield terminal_rpc.unicast(server_id,
                                          imei=imei,
                                          content=send_data)
         if ret["status"] != error_codes.EC_SUCCESS:
             ok = False
     except Exception, e:
         status = error_codes.EC_SYS_ERROR
         logger.exception(e)
         ok = False
Esempio n. 4
0
 def do_request(self):
     res = {"status": error_codes.EC_SUCCESS}
     try:
         imei = self.get_argument("imei")
     except Exception as e:
         res["status"] = error_codes.EC_INVALID_ARGS
     else:
         broadcastor = self.settings["broadcastor"]
         pk = terminal_packets.GetLocationAck(terminal_proto.GenSN(), imei)
         send_data = str(pk)
         ret = yield broadcastor.send_msg_multicast((imei, ), send_data)
         if ret:
             ret_str = "send ok"
         else:
             ret_str = "send fail"
             res["status"] = error_codes.EC_SEND_CMD_FAIL
         self.on_log("s2c send_data:%s ret:%s" % (send_data, ret_str), imei)
     #data = json.dumps(res, ensure_ascii=False, encoding='utf8')
     self.write_obj(res)