mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-11-30 03:46:37 -05:00
initiating call should return call object when link is established
This commit is contained in:
parent
806835f507
commit
a16393d07d
3 changed files with 12 additions and 36 deletions
|
|
@ -145,7 +145,7 @@ class AudioCallManager:
|
|||
return None
|
||||
|
||||
# attempts to initiate a call to the provided destination and returns the link hash on success
|
||||
async def initiate(self, destination_hash: bytes, timeout_seconds: int = 15) -> bytes:
|
||||
async def initiate(self, destination_hash: bytes, timeout_seconds: int = 15) -> AudioCall:
|
||||
|
||||
# determine when to timeout
|
||||
timeout_after_seconds = time.time() + timeout_seconds
|
||||
|
|
@ -177,9 +177,6 @@ class AudioCallManager:
|
|||
# create link
|
||||
link = RNS.Link(server_destination)
|
||||
|
||||
# register link state callbacks
|
||||
link.set_link_established_callback(self.on_link_established)
|
||||
|
||||
# wait until we have established a link, or give up after the configured timeout
|
||||
while link.status is not RNS.Link.ACTIVE and time.time() < timeout_after_seconds:
|
||||
await asyncio.sleep(0.1)
|
||||
|
|
@ -188,19 +185,17 @@ class AudioCallManager:
|
|||
if link.status is not RNS.Link.ACTIVE:
|
||||
raise CallFailedException("Could not establish link to destination.")
|
||||
|
||||
return link.hash
|
||||
|
||||
def on_link_established(self, link: RNS.Link):
|
||||
|
||||
# todo: this can be optional, it's only being sent by default for ui, can be removed
|
||||
link.identify(self.identity)
|
||||
|
||||
# create audio call
|
||||
# link is now established, create audio call
|
||||
audio_call = AudioCall(link, is_outbound=True)
|
||||
|
||||
# handle new outgoing call
|
||||
self.handle_outgoing_call(audio_call)
|
||||
|
||||
# todo: this can be optional, it's only being sent by default for ui, can be removed
|
||||
link.identify(self.identity)
|
||||
|
||||
return audio_call
|
||||
|
||||
|
||||
class AudioCallReceiver:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue