Communication

This outline describes how Anthias handles communication with remote players, receives updates, and manages connections.

  • Core Components:

    • Anthias Server: This is the central component that manages player connections, handles requests, and processes data. [See docs/d2/anthias-diagram-overview.d2]
    • Anthias Websocket: Provides a WebSocket interface for real-time communication between the server and clients. [See docs/d2/anthias-diagram-overview.d2]
    • Anthias Celery: Used for asynchronous task processing, facilitating background operations such as scheduling and notifications. [See docs/d2/anthias-diagram-overview.d2]
    • Redis: Acts as a database, cache, and message broker, enabling efficient communication and data management. [See docs/d2/anthias-diagram-overview.d2, docs/developer-documentation.md]
    • SQLite: Used for storing asset information. [See docs/d2/anthias-diagram-overview.d2, docs/developer-documentation.md]
  • Communication Flow:

    1. User Interaction: Users interact with Anthias through a web interface, sending requests via Nginx. [See docs/d2/anthias-diagram-overview.d2]
    2. NGINX Forwarding: Nginx forwards requests to the Anthias server. [See docs/d2/anthias-diagram-overview.d2]
    3. Server Processing: The server processes requests and interacts with Celery for background tasks. [See docs/d2/anthias-diagram-overview.d2]
    4. Redis as Broker: The server utilizes Redis for data persistence, caching, and message passing. [See docs/d2/anthias-diagram-overview.d2]
    5. WebSocket Connection: The server uses WebSocket for real-time communication with players. [See docs/d2/anthias-diagram-overview.d2]
    6. Player Updates: Players receive updates through the WebSocket connection.
    7. Asset Data: Players access asset data from the SQLite database. [See docs/d2/anthias-diagram-overview.d2]
  • Messaging:

    • ZeroMQ: Anthias uses ZeroMQ for inter-process communication. [See viewer.py, send_zmq_message.py, settings.py]
    • Redis Pub/Sub: Redis Pub/Sub provides a mechanism for broadcasting messages between components, like the viewer and host agent. [See host_agent.py, send_zmq_message.py]
    • WebSocket Channels: WebSockets facilitate real-time communication with players. [See websocket_server_layer.py]
  • Key Code Files:

    • host_agent.py: Contains the host agent logic, including processing messages from Redis Pub/Sub. [See host_agent.py]
    • send_zmq_message.py: Demonstrates sending ZeroMQ messages for specific actions like setting up Wi-Fi or showing splash screens. [See send_zmq_message.py]
    • viewer.py: Implements the ZeroMQ subscriber for viewers, receiving messages and triggering actions. [See viewer.py]
    • settings.py: Defines the ZMQ publisher class, handling message sending to viewers and the WebSocket server. [See settings.py]
    • websocket_server_layer.py: Handles WebSocket connection, translating messages from ZeroMQ to WebSocket clients. [See websocket_server_layer.py]
  • Example Use Cases:

    • Setting Up Wi-Fi on Players: The host agent sends a “setup_wifi” ZeroMQ message to the viewer, configuring the player’s Wi-Fi settings. [See send_zmq_message.py]
    • Displaying Splash Screens: The host agent sends a “show_splash” ZeroMQ message to the viewer, displaying a welcome message. [See send_zmq_message.py]
    • Real-time Updates: The server sends updates to players through the WebSocket connection, ensuring live content and responsiveness. [See websocket_server_layer.py]

This outline highlights the core concepts and components involved in communication within Anthias. By understanding this structure, developers can effectively interact with and extend the system’s communication capabilities.

Top-Level Directory Explanations

ansible/ - Ansible is an open-source configuration management and automation tool. This directory contains Ansible playbooks and roles for managing and configuring the project.

ansible/roles/ - This directory contains Ansible roles, which are reusable collections of tasks and configurations for managing specific aspects of a system.

ansible/roles/network/ - This role manages network configurations.

ansible/roles/screenly/ - This role is specific to the Screenly project and likely contains configurations and tasks related to it.

anthias_app/ - This directory contains the main application codebase for the project, likely written in Django.

anthias_app/migrations/ - This directory contains database migration files for the Django application.

anthias_django/ - This directory may contain additional Django-specific configuration files and code.

api/ - This directory contains the API codebase for the project.

api/serializers/ - This directory contains Django REST Framework serializers for converting data between Python objects and JSON.

api/views/ - This directory contains Django views for handling HTTP requests and rendering responses.

bin/ - This directory contains executable scripts for the project.

lib/ - This directory contains reusable Python modules and libraries for the project.

static/ - This directory contains static files, such as images, CSS, and JavaScript, that are served directly to the user by the web server.

static/js/ - This directory contains JavaScript files.

static/spec/ - This directory contains test files for the static files.

static/spec/jasmine/ - This directory contains Jasmine test files.

templates/ - This directory contains HTML templates used to render dynamic content.

tests/ - This directory contains test files for the project.

tools/ - This directory contains tools and scripts used to develop and maintain the project.

tools/image_builder/ - This tool likely builds and optimizes images for the project.

website/ - This directory contains the website codebase.

webview/ - This directory likely contains configuration files and code for a webview component.

webview/src/ - This directory contains webview source code.