def run_server(): "Run networtables in server mode." global MANAGER try: print("Starting server") MANAGER = ConnectionManager(True) create_messages(TABLE, MANAGER) TABLE["int"] = 1 TABLE["foo"] = 2 TABLE["foobar"] = 3 MANAGER.run(port=PORT) while True: TABLE["int"] += 1 time.sleep(1) except KeyboardInterrupt as _: MANAGER.close_all()
def run_client(): "Run network tables client mode." global MANAGER try: print("Starting client") MANAGER = ConnectionManager(False) create_messages(TABLE, MANAGER) MANAGER.run(port=PORT) time.sleep(2) while True: if "test" in TABLE.entries: TABLE["test"] += "a" else: TABLE["test"] = "h" time.sleep(1) except KeyboardInterrupt as _: MANAGER.close_all()