Implement config storage
This commit is contained in:
@@ -7,14 +7,19 @@ from drb_cdb_api import DRBCDBAPI
|
||||
from drb_cdb_types import ConfigGenerator
|
||||
from server_api import RadioAPIClient
|
||||
from enum import Enum
|
||||
from config import Config
|
||||
|
||||
app_conf = Config()
|
||||
|
||||
# --- Client Configuration ---
|
||||
SERVER_WS_URI = os.getenv("SERVER_WS_URI", "ws://localhost:8765")
|
||||
SERVER_API_URL = os.getenv("SERVER_API_URL", "http://localhost:5000")
|
||||
CLIENT_API_URL = os.getenv("CLIENT_API_URL", "http://localhost:8001")
|
||||
# Generate or define a unique ID for THIS client instance
|
||||
# In a real app, this might come from config or a login process
|
||||
CLIENT_ID = f"client-{uuid.uuid4().hex[:8]}" # TODO - Implement persistent ID
|
||||
|
||||
# Get/set the ID of this node
|
||||
if not app_conf.get("client_id"):
|
||||
app_conf.set("client_id", f"client-{uuid.uuid4().hex[:8]}")
|
||||
CLIENT_ID = app_conf.client_id
|
||||
# ----------------------------
|
||||
|
||||
# Dictionary mapping command names (strings) to local client functions
|
||||
@@ -38,7 +43,6 @@ def command(func):
|
||||
return func
|
||||
|
||||
# --- Define Client-Side Command Handlers (The "API" functions) ---
|
||||
|
||||
# Join server
|
||||
@command
|
||||
async def join_server(system_id, guild_id, channel_id):
|
||||
@@ -114,13 +118,6 @@ async def leave_server(guild_id):
|
||||
|
||||
print("Leave server completed")
|
||||
|
||||
@command
|
||||
async def set_status(status_text):
|
||||
"""Example command: Sets or displays a status."""
|
||||
print(f"\n--- Server Command: set_status ---")
|
||||
print(f"Status updated to: {status_text}")
|
||||
print("----------------------------------")
|
||||
|
||||
@command
|
||||
async def run_task(task_id, duration_seconds):
|
||||
"""Example command: Simulates running a task."""
|
||||
@@ -130,11 +127,7 @@ async def run_task(task_id, duration_seconds):
|
||||
print(f"Task {task_id} finished.")
|
||||
print("------------------------------")
|
||||
|
||||
# Add more command handlers as needed...
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
|
||||
async def receive_commands(websocket):
|
||||
"""Listens for and processes command messages from the server."""
|
||||
async for message in websocket:
|
||||
|
||||
Reference in New Issue
Block a user