本文整理匯總了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()
示例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
示例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)