mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-24 14:40:18 +00:00
Added init option for requiring existing shared instance
This commit is contained in:
parent
6f8d3e882a
commit
f095b9cb8e
@ -184,7 +184,7 @@ class Reticulum:
|
|||||||
"""
|
"""
|
||||||
return Reticulum.__instance
|
return Reticulum.__instance
|
||||||
|
|
||||||
def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None):
|
def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False):
|
||||||
"""
|
"""
|
||||||
Initialises and starts a Reticulum instance. This must be
|
Initialises and starts a Reticulum instance. This must be
|
||||||
done before any other operations, and Reticulum will not
|
done before any other operations, and Reticulum will not
|
||||||
@ -247,6 +247,7 @@ class Reticulum:
|
|||||||
RNS.loglevel = self.requested_loglevel
|
RNS.loglevel = self.requested_loglevel
|
||||||
|
|
||||||
self.is_shared_instance = False
|
self.is_shared_instance = False
|
||||||
|
self.require_shared = require_shared_instance
|
||||||
self.is_connected_to_shared_instance = False
|
self.is_connected_to_shared_instance = False
|
||||||
self.is_standalone_instance = False
|
self.is_standalone_instance = False
|
||||||
self.jobs_thread = None
|
self.jobs_thread = None
|
||||||
@ -334,11 +335,17 @@ class Reticulum:
|
|||||||
interface.bitrate = Reticulum._force_shared_instance_bitrate
|
interface.bitrate = Reticulum._force_shared_instance_bitrate
|
||||||
interface._force_bitrate = Reticulum._force_shared_instance_bitrate
|
interface._force_bitrate = Reticulum._force_shared_instance_bitrate
|
||||||
RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}", RNS.LOG_WARNING)
|
RNS.log(f"Forcing shared instance bitrate of {RNS.prettyspeed(interface.bitrate)}", RNS.LOG_WARNING)
|
||||||
RNS.Transport.interfaces.append(interface)
|
|
||||||
|
|
||||||
self.is_shared_instance = True
|
if self.require_shared == True:
|
||||||
RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG)
|
interface.detach()
|
||||||
self.__start_jobs()
|
self.is_shared_instance = True
|
||||||
|
RNS.log("Existing shared instance required, but this instance started as shared instance. Aborting startup.", RNS.LOG_VERBOSE)
|
||||||
|
|
||||||
|
else:
|
||||||
|
RNS.Transport.interfaces.append(interface)
|
||||||
|
self.is_shared_instance = True
|
||||||
|
RNS.log("Started shared instance interface: "+str(interface), RNS.LOG_DEBUG)
|
||||||
|
self.__start_jobs()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
try:
|
try:
|
||||||
@ -366,6 +373,10 @@ class Reticulum:
|
|||||||
self.is_shared_instance = False
|
self.is_shared_instance = False
|
||||||
self.is_standalone_instance = True
|
self.is_standalone_instance = True
|
||||||
self.is_connected_to_shared_instance = False
|
self.is_connected_to_shared_instance = False
|
||||||
|
|
||||||
|
if self.is_shared_instance and self.require_shared:
|
||||||
|
raise SystemError("No shared instance available, but application that started Reticulum required it")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.is_shared_instance = False
|
self.is_shared_instance = False
|
||||||
self.is_standalone_instance = True
|
self.is_standalone_instance = True
|
||||||
|
Loading…
Reference in New Issue
Block a user