remote: bridge: reject duplicates
This commit is contained in:
parent
e994e7fb24
commit
0a1c959bf9
|
@ -70,6 +70,7 @@ class Bridge:
|
||||||
self.crc = crcmod.predefined.mkCrcFun('crc-ccitt-false')
|
self.crc = crcmod.predefined.mkCrcFun('crc-ccitt-false')
|
||||||
self.queues = {}
|
self.queues = {}
|
||||||
self.callbacks = []
|
self.callbacks = []
|
||||||
|
self.ctrs = {}
|
||||||
|
|
||||||
self.reader = threading.Thread(target = self.readerThread)
|
self.reader = threading.Thread(target = self.readerThread)
|
||||||
self.reader.daemon = True
|
self.reader.daemon = True
|
||||||
|
@ -91,6 +92,7 @@ class Bridge:
|
||||||
self.setChannel(channel)
|
self.setChannel(channel)
|
||||||
|
|
||||||
self.ctr = 0
|
self.ctr = 0
|
||||||
|
|
||||||
def registerCallback(self, callback):
|
def registerCallback(self, callback):
|
||||||
if callback not in self.callbacks:
|
if callback not in self.callbacks:
|
||||||
self.callbacks.append(callback)
|
self.callbacks.append(callback)
|
||||||
|
@ -177,6 +179,8 @@ class Bridge:
|
||||||
if data[-2:] == chr(crc>>8) + chr(crc&0xFF):
|
if data[-2:] == chr(crc>>8) + chr(crc&0xFF):
|
||||||
packet = packets.fromMessage(data)
|
packet = packets.fromMessage(data)
|
||||||
print "received:", packet
|
print "received:", packet
|
||||||
|
if packet.id in self.ctrs and self.ctrs[packet.id] == packet.ctr:
|
||||||
|
return
|
||||||
if isinstance(packet,packets.Ack):
|
if isinstance(packet,packets.Ack):
|
||||||
self.ProcessAck(packet)
|
self.ProcessAck(packet)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue