1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Networked Scene Synchronization for Remote Visualization
//!
//! This module enables real-time scene and component synchronization between a sender (e.g., a headless process or remote server) and a receiver (e.g., a local renderer or visualization client) over the network.
//!
//! ## Overview
//!
//! - **Sender**: Prepares and batches scene/component updates, then transmits them to a receiver. The sender can be a process running remotely (e.g., on an SSH server or in a compute cluster) and is responsible for serializing and sending CPU-side component data.
//! - **Receiver**: Listens for incoming scene/component updates, deserializes them, and applies them to its local ECS world for visualization. The receiver is typically a local or GUI-enabled process.
//!
//! The workflow is analogous to the Python example scripts:
//! - `scene_sender.py`: Sets up a sender, batches scene changes, and sends them over the network.
//! - `scene_receiver.py`: Sets up a receiver, listens for updates, and visualizes the received scene.
//!
//! ## Usage
//!
//! ### Sender Side (Example)
//! ```ignore
//! use gloss_renderer::network::{SceneSender, TransportConfig};
//! // Set up transport configuration (address/port)
//! let config = TransportConfig {
//! address: "127.0.0.1".to_string(),
//! port: 46377,
//! ..Default::default()
//! };
//! let mut sender = SceneSender::new(config);
//! sender.start_listening();
//! sender.try_connect_to_receiver();
//! // ...
//! // Batch and send scene/component updates
//! sender.start_batch();
//! // sender.send_component(...)
//! sender.end_batch();
//! ```
//!
//! ### Receiver Side (Example)
//! ```ignore
//! use gloss_renderer::network::{SceneReceiver, TransportConfig, SceneReceiverPlugin};
//! // Set up transport configuration (address/port)
//! let config = TransportConfig {
//! address: "127.0.0.1".to_string(),
//! port: 46377,
//! ..Default::default()
//! };
//! let mut receiver = SceneReceiver::new(config);
//! viewer.add_resource(receiver);
//! viewer.insert_plugin(SceneReceiverPlugin::new(true));
//! ```
//!
//! ## Notes
//!
//! - Only CPU-side components that implement `serde::Serialize` can be sent. GPU-side data must be recreated on the receiver.
//! - Batching updates (between `start_batch` and `end_batch`) ensures atomic application of scene changes.
//! - The receiver can be run as a plugin or resource in a viewer or ECS system.
//! - The sender and receiver must agree on the set of serializable components and their registration.
//!
//! See the Python scripts `scene_sender.py` and `scene_receiver.py` for a practical workflow analogy.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
use ;
pub use *;
pub use *;
// Trait for checking if components can be sent over the network.
/// This trait must be implemented for all components that want network functionality.
/// Usually this is implemented for Serializable objects like `SerializableVerts` and not for Verts themselves
/// You can usually implement both `NetworkSendable` and `NetworkReceivable ` using the macro `impl_network_sendable_and_receivable `
/// Trait for components that can be received over the network.