Added check for link state before sending
This commit is contained in:
parent
07484725a0
commit
bbfdd37935
@ -299,6 +299,7 @@ class Channel(contextlib.AbstractContextManager):
|
|||||||
:param callback: handler to remove
|
:param callback: handler to remove
|
||||||
"""
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
|
if callback in self._message_callbacks:
|
||||||
self._message_callbacks.remove(callback)
|
self._message_callbacks.remove(callback)
|
||||||
|
|
||||||
def _shutdown(self):
|
def _shutdown(self):
|
||||||
@ -464,6 +465,7 @@ class LinkChannelOutlet(ChannelOutletBase):
|
|||||||
|
|
||||||
def send(self, raw: bytes) -> RNS.Packet:
|
def send(self, raw: bytes) -> RNS.Packet:
|
||||||
packet = RNS.Packet(self.link, raw, context=RNS.Packet.CHANNEL)
|
packet = RNS.Packet(self.link, raw, context=RNS.Packet.CHANNEL)
|
||||||
|
if self.link.status == RNS.Link.ACTIVE:
|
||||||
packet.send()
|
packet.send()
|
||||||
return packet
|
return packet
|
||||||
|
|
||||||
@ -485,6 +487,9 @@ class LinkChannelOutlet(ChannelOutletBase):
|
|||||||
return True # had issues looking at Link.status
|
return True # had issues looking at Link.status
|
||||||
|
|
||||||
def get_packet_state(self, packet: TPacket) -> MessageState:
|
def get_packet_state(self, packet: TPacket) -> MessageState:
|
||||||
|
if packet.receipt == None:
|
||||||
|
return MessageState.MSGSTATE_FAILED
|
||||||
|
|
||||||
status = packet.receipt.get_status()
|
status = packet.receipt.get_status()
|
||||||
if status == RNS.PacketReceipt.SENT:
|
if status == RNS.PacketReceipt.SENT:
|
||||||
return MessageState.MSGSTATE_SENT
|
return MessageState.MSGSTATE_SENT
|
||||||
|
Loading…
Reference in New Issue
Block a user