当前位置: 首页>>代码示例>>Python>>正文


Python MQMessage.set方法代码示例

本文整理汇总了Python中domogik.mq.message.MQMessage.set方法的典型用法代码示例。如果您正苦于以下问题:Python MQMessage.set方法的具体用法?Python MQMessage.set怎么用?Python MQMessage.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在domogik.mq.message.MQMessage的用法示例。


在下文中一共展示了MQMessage.set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _on_message

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import set [as 别名]
    def _on_message(self, msg):
        """Helper method called on message receive.

        msg is a list w/ the message parts
        """
        # 1st part is empty
        msg.pop(0)
        # 2nd part is protocol version
        # TODO: version check
        proto = msg.pop(0)
        # 3rd part is message type
        msg_type = msg.pop(0)
        # XXX: hardcoded message types!
        # any message resets the liveness counter
        self.need_handshake = False
        self.curr_liveness = self.HB_LIVENESS
        if msg_type == b'\x05': # disconnect
            self.curr_liveness = 0 # reconnect will be triggered by hb timer
        elif msg_type == b'\x02': # request
            # remaining parts are the user message
            envelope, msg = split_address(msg)
            envelope.append(b'')
            envelope = [ b'', self._proto_version, b'\x03'] + envelope # REPLY
            self.envelope = envelope
            mes = MQMessage()
            mes.set(msg)
            self.on_mdp_request(mes)
        else:
            # invalid message
            # ignored
            pass
        return
开发者ID:Basilic,项目名称:domogik,代码行数:34,代码来源:worker.py

示例2: request

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import set [as 别名]
    def request(self, service, msg, timeout=None):
        """Send the given message.

        :param msg:     message parts to send.
        :type msg:      list of str
        :param timeout: time to wait in milliseconds.
        :type timeout:  int
        
        :rtype : message parts
        """
	ret = self.rawrequest( service, msg, timeout)
	msg = None
	if ret:
	    msg = MQMessage()
            msg.set(ret)
        return msg
开发者ID:MagnetonBora,项目名称:zmq,代码行数:18,代码来源:client.py


注:本文中的domogik.mq.message.MQMessage.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。