ehh python
This commit is contained in:
parent
b3ca85b690
commit
4c2fc7969f
1 changed files with 14 additions and 12 deletions
26
server.py
26
server.py
|
@ -20,7 +20,7 @@ def write_ob_status(status: bool) -> None:
|
||||||
if not os.path.exists("/music/ob_state.conf"):
|
if not os.path.exists("/music/ob_state.conf"):
|
||||||
print("OB State file does not exist. Bailing.")
|
print("OB State file does not exist. Bailing.")
|
||||||
return
|
return
|
||||||
with open("/music/ob_state.conf", "w") as fd:
|
with open("/music/ob_state.conf", "r+") as fd:
|
||||||
content = fd.read()
|
content = fd.read()
|
||||||
if "ws" in content:
|
if "ws" in content:
|
||||||
content = re.sub(file_contents_ex, "ws=" + str(1 if status else 0), content)
|
content = re.sub(file_contents_ex, "ws=" + str(1 if status else 0), content)
|
||||||
|
@ -139,17 +139,19 @@ class Session(object):
|
||||||
|
|
||||||
@self.pc.on("iceconnectionstatechange") # type: ignore
|
@self.pc.on("iceconnectionstatechange") # type: ignore
|
||||||
async def on_iceconnectionstatechange() -> None:
|
async def on_iceconnectionstatechange() -> None:
|
||||||
assert self.pc is not None
|
if self.pc is None:
|
||||||
print(
|
print(self.connection_id, "ICE connection state change, but the PC is None!")
|
||||||
self.connection_id,
|
else:
|
||||||
"ICE connection state is {}".format(self.pc.iceConnectionState),
|
print(
|
||||||
)
|
self.connection_id,
|
||||||
if self.pc.iceConnectionState == "failed":
|
"ICE connection state is {}".format(self.pc.iceConnectionState),
|
||||||
await self.pc.close()
|
)
|
||||||
self.pc = None
|
if self.pc.iceConnectionState == "failed":
|
||||||
if self.websocket is not None:
|
await self.pc.close()
|
||||||
await self.websocket.close(1008)
|
self.pc = None
|
||||||
return
|
if self.websocket is not None:
|
||||||
|
await self.websocket.close(1008)
|
||||||
|
return
|
||||||
|
|
||||||
@self.pc.on("track") # type: ignore
|
@self.pc.on("track") # type: ignore
|
||||||
async def on_track(track: MediaStreamTrack) -> None:
|
async def on_track(track: MediaStreamTrack) -> None:
|
||||||
|
|
Loading…
Reference in a new issue