]> www.average.org Git - loctrkd.git/blobdiff - loctrkd/watch.py
Adjust config to changing messaging topology
[loctrkd.git] / loctrkd / watch.py
index 738cfe230be94dfb415a6c40b21045e8e1583960..8e962bc2278dcef0b8eda170116dae0be702df2a 100644 (file)
@@ -8,21 +8,12 @@ from typing import Any, cast, List
 import zmq
 
 from . import common
+from .protomodule import ProtoModule
 from .zmsg import Bcast
 
 log = getLogger("loctrkd/watch")
 
 
-class ProtoModule:
-    @staticmethod
-    def proto_handled(proto: str) -> bool:
-        ...
-
-    @staticmethod
-    def parse_message(packet: bytes, is_incoming: bool = True) -> Any:
-        ...
-
-
 pmods: List[ProtoModule] = []
 
 
@@ -30,7 +21,7 @@ def runserver(conf: ConfigParser) -> None:
     global pmods
     pmods = [
         cast(ProtoModule, import_module("." + modnm, __package__))
-        for modnm in conf.get("collector", "protocols").split(",")
+        for modnm in conf.get("common", "protocols").split(",")
     ]
     # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
     zctx = zmq.Context()  # type: ignore
@@ -43,7 +34,7 @@ def runserver(conf: ConfigParser) -> None:
             zmsg = Bcast(zsub.recv())
             print("I" if zmsg.is_incoming else "O", zmsg.proto, zmsg.imei)
             for pmod in pmods:
-                if pmod.proto_handled(zmsg.proto.startswith):
+                if pmod.proto_handled(zmsg.proto):
                     msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming)
                     print(msg)
     except KeyboardInterrupt: