sunshine: improve launching of pairing

This commit is contained in:
a-kenji
2024-03-20 09:55:25 +01:00
parent 65e7449d15
commit afb4a2a936
3 changed files with 11 additions and 7 deletions

View File

@@ -10,18 +10,19 @@ class MoonlightPairing:
self.found = threading.Event()
def init_pairing(self, host: str, pin: str) -> bool:
# host = f"[{host}]"
args = ["moonlight", "pair", host, "--pin", pin]
print("Trying to pair")
try:
self.process = subprocess.Popen(
args, stderr=subprocess.PIPE, stdout=subprocess.PIPE
)
print(f"Running command: {args}")
self.process = subprocess.Popen(args, stdout=subprocess.PIPE)
print("Pairing initiated")
thread = threading.Thread(
target=self.stream_output,
args=('Latest supported GFE server: "99.99.99.99"',),
)
thread.start()
print("Thread started")
return True
except Exception as e:
print(
@@ -51,6 +52,8 @@ class MoonlightPairing:
self.found.set()
break
def wait_until_started(self) -> None:
self.found.wait()
print("Started up.")
def wait_until_started(self, timeout: int = 10) -> None:
if self.found.wait(timeout):
print("Started up.")
else:
print("Starting up took took too long. Terminated the process.")