fix a client counting bug by deferring client instantiation

This commit is contained in:
Jakob Ketterl 2022-01-03 15:19:12 +01:00
parent 60f57bf206
commit 2ce7d943fa

View File

@ -492,17 +492,17 @@ class HandshakeMessageHandler(Handler):
client = None client = None
if "type" in handshake: if "type" in handshake:
if handshake["type"] == "receiver": if handshake["type"] == "receiver":
client = OpenWebRxReceiverClient(conn) client = OpenWebRxReceiverClient
elif handshake["type"] == "map": elif handshake["type"] == "map":
client = MapConnection(conn) client = MapConnection
else: else:
logger.warning("invalid connection type: %s", handshake["type"]) logger.warning("invalid connection type: %s", handshake["type"])
if client is not None: if client is not None:
logger.debug("handshake complete, handing off to %s", type(client).__name__) logger.debug("handshake complete, handing off to %s", client.__name__)
# hand off all further communication to the correspondig connection # hand off all further communication to the correspondig connection
conn.send("CLIENT DE SERVER server=openwebrx version={version}".format(version=openwebrx_version)) conn.send("CLIENT DE SERVER server=openwebrx version={version}".format(version=openwebrx_version))
conn.setMessageHandler(client) conn.setMessageHandler(client(conn))
else: else:
logger.warning('invalid handshake received') logger.warning('invalid handshake received')
else: else: