mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 13:30:36 +01:00
Get link establishment rates via service on Android
This commit is contained in:
parent
3a952334ad
commit
6038bc541c
@ -1578,6 +1578,44 @@ class SidebandCore():
|
||||
RNS.log(ed, RNS.LOG_DEBUG)
|
||||
return ed
|
||||
|
||||
def _get_destination_establishment_rate(self, destination_hash):
|
||||
try:
|
||||
mr = self.message_router
|
||||
oh = destination_hash
|
||||
ol = None
|
||||
if oh in mr.direct_links:
|
||||
ol = mr.direct_links[oh]
|
||||
elif oh in mr.backchannel_links:
|
||||
ol = mr.backchannel_links[oh]
|
||||
|
||||
if ol != None:
|
||||
ler = ol.get_establishment_rate()
|
||||
if ler:
|
||||
return ler
|
||||
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
RNS.trace_exception(e)
|
||||
return None
|
||||
|
||||
def get_destination_establishment_rate(self, destination_hash):
|
||||
if not RNS.vendor.platformutils.is_android():
|
||||
return self._get_destination_establishment_rate(destination_hash)
|
||||
else:
|
||||
if self.is_service:
|
||||
return self._get_destination_establishment_rate(destination_hash)
|
||||
else:
|
||||
try:
|
||||
if self.rpc_connection == None:
|
||||
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
|
||||
self.rpc_connection.send({"get_destination_establishment_rate": destination_hash})
|
||||
response = self.rpc_connection.recv()
|
||||
return response
|
||||
except Exception as e:
|
||||
ed = "Error while getting destination link etablishment rate over RPC: "+str(e)
|
||||
RNS.log(ed, RNS.LOG_DEBUG)
|
||||
return None
|
||||
|
||||
def __start_rpc_listener(self):
|
||||
try:
|
||||
@ -1621,6 +1659,8 @@ class SidebandCore():
|
||||
connection.send(True)
|
||||
elif "get_plugins_info" in call:
|
||||
connection.send(self._get_plugins_info())
|
||||
elif "get_destination_establishment_rate" in call:
|
||||
connection.send(self._get_destination_establishment_rate(call["get_destination_establishment_rate"]))
|
||||
elif "send_message" in call:
|
||||
args = call["send_message"]
|
||||
send_result = self.send_message(
|
||||
|
@ -796,14 +796,10 @@ class RVDetails(MDRecycleView):
|
||||
self.entries.append({"icon": "routes", "text": f"Current path on [b]{nhi}[/b]", "on_release": pass_job})
|
||||
|
||||
try:
|
||||
mr = self.delegate.app.sideband.message_router
|
||||
oh = self.delegate.object_hash
|
||||
if oh in mr.direct_links:
|
||||
ol = mr.direct_links[oh]
|
||||
ler = ol.get_establishment_rate()
|
||||
if ler:
|
||||
lers = RNS.prettyspeed(ler, "b")
|
||||
self.entries.append({"icon": "lock-check-outline", "text": f"Direct link established, LER is [b]{lers}[/b]", "on_release": pass_job})
|
||||
ler = self.delegate.app.sideband.get_destination_establishment_rate(self.delegate.object_hash)
|
||||
if ler:
|
||||
lers = RNS.prettyspeed(ler, "b")
|
||||
self.entries.append({"icon": "lock-check-outline", "text": f"Direct link established, LER is [b]{lers}[/b]", "on_release": pass_job})
|
||||
except Exception as e:
|
||||
RNS.trace_exception(e)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user