From 78df1ca74ccee09a83b9e30eb307b7f93056e469 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 25 May 2020 18:28:29 +0000 Subject: [PATCH] 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. --- webrtc/signalling/simple_server.py | 20 +++++++++++--------- 1 file 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 () -- 2.7.4