當前位置: 首頁>>代碼示例>>Python>>正文


Python Receiver.receive方法代碼示例

本文整理匯總了Python中receiver.Receiver.receive方法的典型用法代碼示例。如果您正苦於以下問題:Python Receiver.receive方法的具體用法?Python Receiver.receive怎麽用?Python Receiver.receive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在receiver.Receiver的用法示例。


在下文中一共展示了Receiver.receive方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from receiver import Receiver [as 別名]
# 或者: from receiver.Receiver import receive [as 別名]
def main():
	sender = Sender('localhost')
	sender.connect()
	sender.create_queue('inbox')
	sender.send_message('inbox', 'hello')
	sender.disconnect()

	receiver = Receiver('localhost')
	receiver.connect()
	receiver.receive('inbox')
	receiver.disconnect()
開發者ID:AzharWeb,項目名稱:sandbox,代碼行數:13,代碼來源:program.py

示例2: handle_block

# 需要導入模塊: from receiver import Receiver [as 別名]
# 或者: from receiver.Receiver import receive [as 別名]
def handle_block(new_block_size, E, K):
    # Simulator.simulate returns the number of bit errors in each block
    bit_errors = Simulator.simulate(new_block_size, E)

    Statistics.update(Statistics.total_transmitions)
    if (bit_errors != 0):
        Statistics.update(Statistics.block_errors)
    try:
        Receiver.receive(bit_errors)
        Statistics.update(Statistics.no_error)
        Statistics.update(Statistics.correctly_received_blocks)
        return 0
    except OneBitError:
        Statistics.update(Statistics.one_bit_error)
        if (K != 0):
            Statistics.update(Statistics.correctly_received_blocks)
            # Assume: Fixing the error requires 0 trials_time units
            return 0
        return bit_errors
    except MultipleBitErrors:
        Statistics.update(Statistics.multiple_bit_errors)
        return bit_errors
開發者ID:Solanar,項目名稱:CMPUT313_Asn1,代碼行數:24,代碼來源:main.py

示例3: __init__

# 需要導入模塊: from receiver import Receiver [as 別名]
# 或者: from receiver.Receiver import receive [as 別名]
class Connection:

    def __init__(self, packet_sender):
        print 'Init Connection'

        self.ee = EventEmitter()

        self._sender = Sender(packet_sender)
        self._receiver = Receiver(packet_sender)

        @self._receiver.ee.on('data')
        def on_data(data):
            self.ee.emit('data', data)

    def send(self, data):
        self._sender.send(data)

    def receive(self, packet):
        if packet.getIsAcknowledgement():
            self._sender.verifyAcknowledgement(packet.getSequenceNumber())
        else:
            self._receiver.receive(packet)
開發者ID:hoffmabc,項目名稱:python-rudp,代碼行數:24,代碼來源:connection.py


注:本文中的receiver.Receiver.receive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。