Clients Module¶
[!WARNING] Experimental. This module is a prototype and needs a major refactor. The current serialization (pickle + base64 + msgpack), error handling, and reconnection logic are not production-grade. Use for experimentation only.
The REvoDesign.clients package provides WebSocket-based networking for
real-time collaboration between REvoDesign instances. Two peer instances can
connect via WebSockets to share views, mutant trees, configurations, and
PyMOL sessions.
Architecture¶
┌─────────────────┐ WebSocket ┌─────────────────┐
│ Instance A │◄─────────────────────────────►│ Instance B │
│ (Server mode) │ ws://host:port │ (Client mode) │
│ │ │ │
│ REvoDesign- │ msgpack + pickle + │ REvoDesign- │
│ WebSocketServer│ base64 serialization │ WebSocketClient│
└─────────────────┘ └─────────────────┘
One instance starts a WebSocket server (REvoDesignWebSocketServer), and
other instances connect as clients (REvoDesignWebSocketClient). The server
supports optional key-based authentication, view broadcasting, and mutant
tree synchronisation.
Supported data types¶
Data exchanged between peers is serialized via pickle, encoded in base64,
and packed with msgpack. The Broadcaster class enforces a whitelist of
allowed data types:
MutantTree-- mutant tree for synchronised mutagenesisPyMOL_prompt-- PyMOL command to execute on peersPyMOL_selection-- atom selectionsViewUpdate-- camera view matrixConfigItem-- configuration item changesClientInfo-- peer metadata (user, node, OS)Text-- plain text chatUUID-- client identityUserTree-- peer list for the UI tree widgetPyMOL_session-- serialised PyMOL sessionMessageStack-- batched messages
Module Reference¶
The module is located at src/REvoDesign/clients/QtSocketConnector.py (namespace package, no __init__.py). Key classes:
Client— Represents a connected peer with identity, socket, and metadata.MeetingRoom— Manages connected clients, tracks attendance, and handles message routing.Broadcaster— Sends data to all connected clients with type whitelisting and serialization.REvoDesignWebSocketServer— Qt-based WebSocket server listening on a configurable port with optional key authentication.REvoDesignWebSocketClient— Qt-based WebSocket client that connects to a remote server instance.