示例#1
0
 def parser_mxid(mxid):
     """
     根据jid,accesstoken产生maadap的mxid
     :param access_token: register的访问token
     :param jid: jabber id
     :return:字符串
     """
     mxid = XXTEACrypto.instance(MxidMgr.xxtea_key).decrypt(mxid)
     return mxid.split(MxidMgr.separator)
示例#2
0
文件: mqtt.py 项目: cash2one/FundTray
 def mqtt_onmessage_param_decorator(self, mqttc, userdata, msg):
     logger.info("MQTT:onmessage msg:%s" % msg)
     msg.payload = XXTEACrypto.instance(xxtea_key).decrypt(msg.payload) \
         if xxtea_key and msg.payload\
         else msg.payload
     msg.payload = ujson.loads(msg.payload) \
         if use_json_loads and msg.payload \
         else msg.payload
     return fun(self, mqttc, userdata, msg)
示例#3
0
 def mqtt_publish_param_decorator(self, topic, payload=None, *args, **kwargs):
     logger.info("MQTT:publish topic:%s, payload:%s" % (topic, payload))
     payload.__setitem__('sign', mqtt_sign) if mqtt_sign else None
     payload = ujson.dumps(payload) \
         if use_json_dumps and payload is not None\
         else payload
     payload = XXTEACrypto.instance(xxtea_key).encrypt(payload) \
         if xxtea_key and payload is not None\
         else payload
     return fun(self, topic, payload, *args, **kwargs)
示例#4
0
 def gen_mxid(access_token, jid):
     """
     根据jid,accesstoken产生maadap的mxid
     :param access_token: register的访问token
     :param jid: jabber id
     :return:字符串
     """
     assert isinstance(jid, str)
     mxid = "%s%s%s" % (jid, MxidMgr.separator, access_token)
     return XXTEACrypto.instance(MxidMgr.xxtea_key).encrypt(mxid)
示例#5
0
 def mqtt_onmessage_param_decorator(self, mqttc, userdata, msg):
     try:
         msg.payload = XXTEACrypto.instance(xxtea_key).decrypt(msg.payload) \
             if xxtea_key and msg.payload\
             else msg.payload
         msg.payload = ujson.loads(msg.payload) \
             if use_json_loads and msg.payload \
             else msg.payload
     except:
         logger.warn("mqtt_onmessage_decorator Error!!! topic:%s payload:%s" % (msg.topic, msg.payload))
         return
     return fun(self, mqttc, userdata, msg)
示例#6
0
文件: mqtt.py 项目: cash2one/FundTray
 def mqtt_publish_param_decorator(self,
                                  topic,
                                  payload=None,
                                  *args,
                                  **kwargs):
     logger.info("MQTT:publish topic:%s, payload:%s" % (topic, payload))
     payload.__setitem__('sign', mqtt_sign) if mqtt_sign else None
     payload = ujson.dumps(payload) \
         if use_json_dumps and payload is not None\
         else payload
     payload = XXTEACrypto.instance(xxtea_key).encrypt(payload) \
         if xxtea_key and payload is not None\
         else payload
     return fun(self, topic, payload, *args, **kwargs)
示例#7
0
 def mqtt_onmessage_param_decorator(self, mqttc, userdata, msg):
     try:
         msg.payload = XXTEACrypto.instance(xxtea_key).decrypt(msg.payload) \
             if xxtea_key and msg.payload\
             else msg.payload
         msg.payload = ujson.loads(msg.payload) \
             if use_json_loads and msg.payload \
             else msg.payload
     except:
         logger.warn(
             "mqtt_onmessage_decorator Error!!! topic:%s payload:%s" %
             (msg.topic, msg.payload))
         return
     return fun(self, mqttc, userdata, msg)