summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-05-25 18:28:29 +0000
committerMatthew Waters <matthew@centricular.com>2020-06-18 23:34:48 +1000
commit78df1ca74ccee09a83b9e30eb307b7f93056e469 (patch)
tree2fe626c07c496f153c0828cba13ed729f9ca8126
parent180e1ce24c7742b983f0f662ab2d0421988272e3 (diff)
simple_server: Correctly pass health option
It was completely ignored. Also don't de-serialize options. Just parse them directly in `__init__`. Less error-prone.
-rwxr-xr-xwebrtc/signalling/simple_server.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/webrtc/signalling/simple_server.py b/webrtc/signalling/simple_server.py
index 7da614b..7f9123e 100755
--- a/webrtc/signalling/simple_server.py
+++ b/webrtc/signalling/simple_server.py
@@ -17,9 +17,10 @@ import argparse
import http
import concurrent
+
class WebRTCSimpleServer(object):
- def __init__(self, addr, port, keepalive_timeout, disable_ssl, certpath, health_path=None):
+ def __init__(self, options):
############### Global data ###############
# Format: {uid: (Peer WebSocketServerProtocol,
@@ -34,17 +35,18 @@ class WebRTCSimpleServer(object):
# Room dict with a set of peers in each room
self.rooms = dict()
- self.keepalive_timeout = keepalive_timeout
- self.addr = addr
- self.port = port
- self.disable_ssl = disable_ssl
- self.certpath = certpath
- self.health_path = health_path
+ # Options
+ self.addr = options.addr
+ self.port = options.port
+ self.keepalive_timeout = options.keepalive_timeout
+ self.cert_path = options.cert_path
+ self.disable_ssl = options.disable_ssl
+ self.health_path = options.health
############### Helper functions ###############
async def health_check(self, path, request_headers):
- if path == self.health_part:
+ if path == self.health_path:
return http.HTTPStatus.OK, [], b"OK\n"
return None
@@ -280,7 +282,7 @@ def main():
loop = asyncio.get_event_loop()
- r = WebRTCSimpleServer(options.addr, options.port, options.keepalive_timeout, options.disable_ssl, options.cert_path)
+ r = WebRTCSimpleServer(options)
loop.run_until_complete (r.run())
loop.run_forever ()