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


Python message.Message类代码示例

本文整理汇总了Python中protos.message.Message的典型用法代码示例。如果您正苦于以下问题:Python Message类的具体用法?Python Message怎么用?Python Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: func

        def func(node, *args):
            msgID = sha1(str(random.getrandbits(255))).digest()

            m = Message()
            m.messageID = msgID
            m.sender.MergeFrom(self.sourceNode.getProto())
            m.command = Command.Value(name.upper())
            m.protoVer = PROTOCOL_VERSION
            for arg in args:
                m.arguments.append(str(arg))
            m.testnet = self.multiplexer.testnet
            data = m.SerializeToString()

            address = (node.ip, node.port)
            relay_addr = None
            if node.nat_type == SYMMETRIC or \
                    (node.nat_type == RESTRICTED and self.sourceNode.nat_type == SYMMETRIC):
                relay_addr = node.relay_node

            d = defer.Deferred()
            if m.command != HOLE_PUNCH:
                timeout = reactor.callLater(self._waitTimeout, self.timeout, node)
                self._outstanding[msgID] = [d, address, timeout]
                self.log.debug("calling remote function %s on %s (msgid %s)" % (name, address, b64encode(msgID)))

            self.multiplexer.send_message(data, address, relay_addr)

            if self.multiplexer[address].state != State.CONNECTED and \
                            node.nat_type == RESTRICTED and \
                            self.sourceNode.nat_type != SYMMETRIC:
                self.hole_punch(Node(digest("null"), node.relay_node[0], node.relay_node[1], nat_type=FULL_CONE),
                                address[0], address[1], "True")
                self.log.debug("sending hole punch message to %s" % address[0] + ":" + str(address[1]))

            return d
开发者ID:gjhiggins,项目名称:OpenBazaar-Server,代码行数:35,代码来源:rpcudp.py

示例2: func

        def func(address, *args):
            msgID = sha1(str(random.getrandbits(255))).digest()
            d = defer.Deferred()
            if name != "hole_punch":
                seed = SEED_NODE_TESTNET if self.multiplexer.testnet else SEED_NODE
                if address in self.multiplexer and self.multiplexer[address].state == State.CONNECTED:
                    timeout = timeout = reactor.callLater(self._waitTimeout, self.timeout, address)
                else:
                    timeout = reactor.callLater(self._waitTimeout, self.hole_punch, seed,
                                                address[0], address[1], "True", msgID)
                self._outstanding[msgID] = [d, address, timeout]
                self.log.debug("calling remote function %s on %s (msgid %s)" % (name, address, b64encode(msgID)))
            elif args[3] in self._outstanding:
                prev_msgID = args[3]
                args = args[:3]
                deferred, addr, hp = self._outstanding[prev_msgID]  # pylint: disable=W0612
                timeout = reactor.callLater(3, self.timeout, addr)
                self._outstanding[prev_msgID] = [deferred, addr, timeout]
                self.log.debug("sending hole punch message to %s" % args[0] + ":" + str(args[1]))

            m = Message()
            m.messageID = msgID
            m.sender.MergeFrom(self.sourceNode.getProto())
            m.command = Command.Value(name.upper())
            m.protoVer = PROTOCOL_VERSION
            for arg in args:
                m.arguments.append(str(arg))
            m.testnet = self.multiplexer.testnet
            data = m.SerializeToString()

            self.multiplexer.send_message(data, address)
            return d
开发者ID:yynil,项目名称:OpenBazaar-Server,代码行数:32,代码来源:rpcudp.py

示例3: _sendResponse

 def _sendResponse(self, response, funcname, msgID, sender, connection):
     if self.noisy:
         self.log.debug("Sending response for msg id %s to %s" % (b64encode(msgID), sender))
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.proto)
     m.command = Command.Value(funcname.upper())
     for arg in response:
         m.arguments.append(str(arg))
     data = m.SerializeToString()
     connection.send_message(data)
开发者ID:the9ull,项目名称:OpenBazaar-Server,代码行数:11,代码来源:rpcudp.py

示例4: func

 def func(address, *args):
     msgID = sha1(str(random.getrandbits(255))).digest()
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.proto)
     m.command = Command.Value(name.upper())
     m.protoVer = PROTOCOL_VERSION
     for arg in args:
         m.arguments.append(str(arg))
     m.testnet = self.multiplexer.testnet
     data = m.SerializeToString()
     d = defer.Deferred()
     self._outstanding[msgID] = [d, address]
     self.multiplexer.send_message(data, address)
     self.log.debug("calling remote function %s on %s (msgid %s)" % (name, address, b64encode(msgID)))
     return d
开发者ID:tasatko,项目名称:OpenBazaar-Server,代码行数:16,代码来源:rpcudp.py

示例5: func

 def func(address, *args):
     msgID = sha1(str(random.getrandbits(255))).digest()
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.proto)
     m.command = Command.Value(name.upper())
     for arg in args:
         m.arguments.append(arg)
     data = m.SerializeToString()
     if self.noisy:
         self.log.msg("calling remote function %s on %s (msgid %s)" % (name, address, b64encode(msgID)))
     self.multiplexer.send_message(data, address)
     d = defer.Deferred()
     timeout = reactor.callLater(self._waitTimeout, self._timeout, msgID)
     self._outstanding[msgID] = (d, timeout)
     return d
开发者ID:Renelvon,项目名称:Network,代码行数:16,代码来源:rpcudp.py

示例6: func

 def func(address, *args):
     msgID = sha1(str(random.getrandbits(255))).digest()
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.sourceNode.getProto())
     m.command = Command.Value(name.upper())
     m.protoVer = PROTOCOL_VERSION
     for arg in args:
         m.arguments.append(str(arg))
     m.testnet = self.multiplexer.testnet
     data = m.SerializeToString()
     d = defer.Deferred()
     if name != "hole_punch":
         seed = SEED_NODE_TESTNET if self.multiplexer.testnet else SEED_NODE
         hole_punch = reactor.callLater(3, self.hole_punch, seed, address[0], address[1], "True")
         if address in self.multiplexer:
             hole_punch.cancel()
         self._outstanding[msgID] = [d, address, hole_punch]
         self.log.debug("calling remote function %s on %s (msgid %s)" % (name, address, b64encode(msgID)))
     else:
         self.log.debug("sending hole punch message to %s" % args[0] + ":" + str(args[1]))
     self.multiplexer.send_message(data, address)
     return d
开发者ID:EgoCenter,项目名称:OpenBazaar-Server,代码行数:23,代码来源:rpcudp.py

示例7: _sendResponse

 def _sendResponse(self, response, funcname, msgID, sender, connection):
     self.log.debug("sending response for msg id %s to %s" % (b64encode(msgID), sender))
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.sourceNode.getProto())
     m.protoVer = PROTOCOL_VERSION
     m.testnet = self.multiplexer.testnet
     if response is None:
         m.command = NOT_FOUND
     else:
         m.command = Command.Value(funcname.upper())
         if not isinstance(response, list):
             response = [response]
         for arg in response:
             m.arguments.append(str(arg))
     m.signature = self.signing_key.sign(m.SerializeToString())[:64]
     connection.send_message(m.SerializeToString())
开发者ID:tcharding,项目名称:OpenBazaar-Server,代码行数:17,代码来源:rpcudp.py

示例8: _sendResponse

 def _sendResponse(self, response, funcname, msgID, sender, connection):
     self.log.debug("sending response for msg id %s to %s" % (b64encode(msgID), sender))
     m = Message()
     m.messageID = msgID
     m.sender.MergeFrom(self.proto)
     m.protoVer = PROTOCOL_VERSION
     m.testnet = self.multiplexer.testnet
     if response is None:
         m.command = NOT_FOUND
     else:
         m.command = Command.Value(funcname.upper())
         for arg in response:
             m.arguments.append(str(arg))
     data = m.SerializeToString()
     connection.send_message(data)
开发者ID:toastchee,项目名称:OpenBazaar-Server,代码行数:15,代码来源:rpcudp.py


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