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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*!
Provides integration for [`bevy_replicon`](https://docs.rs/bevy_replicon) for [`bevy_renet`](https://docs.rs/bevy_renet).
# Getting started
This guide assumes that you have already read the [quick start guide](https://docs.rs/bevy_replicon#quick-start)
for `bevy_replicon`.
## Modules
Renet API is re-exported from this drate under [`renet`] module. Features from `bevy_renet` are exposed via
`renet_*` features, which also re-export the corresponding transport modules. Like in `bevy_renet`, the netcode
transport is enabled by default.
So you don't need to include `bevy_renet` or `renet` in your `Cargo.toml`.
## Plugins
Add [`RepliconRenetPlugins`] along with [`RepliconPlugins`]:
```
use bevy::{prelude::*, state::app::StatesPlugin};
use bevy_replicon::prelude::*;
use bevy_replicon_renet::RepliconRenetPlugins;
let mut app = App::new();
app.add_plugins((MinimalPlugins, StatesPlugin, RepliconPlugins, RepliconRenetPlugins));
```
Similar to Replicon, we provide `client` and `server` features. These automatically enable the corresponding
features in `bevy_replicon`.
The plugins in [`RepliconRenetPlugins`] automatically include the Renet plugins, so you don't need to add
them manually. If the `renet_transport` feature is enabled, the netcode plugins will also be added automatically.
## Server and client creation
Just like with regular `bevy_renet`, you need to create the
[`RenetClient`](renet::RenetClient) and [`NetcodeClientTransport`](bevy_renet::netcode::NetcodeClientTransport) **or**
[`RenetServer`](renet::RenetServer) and [`NetcodeServerTransport`](bevy_renet::netcode::NetcodeServerTransport)
resources from Renet.
For steam transport you need to activate the corresponding feature and use its transport resource instead.
This crate will automatically manage their integration with Replion.
<div class="warning">
Never insert client and server resources in the same app, it will cause a replication loop.
See the Replicon's quick start guide for more details.
</div>
The only Replicon-specific part is channels. You need to get them from the [`RepliconChannels`] resource.
This crate provides the [`RenetChannelsExt`] extension trait to conveniently create Renet channels from it:
```
use bevy::prelude::*;
use bevy_replicon::prelude::*;
use bevy_replicon_renet::{renet::ConnectionConfig, RenetChannelsExt};
fn init(channels: Res<RepliconChannels>) {
let connection_config = ConnectionConfig {
server_channels_config: channels.server_configs(),
client_channels_config: channels.client_configs(),
..Default::default()
};
// Use this config for `RenetServer` or `RenetClient`
}
```
For a full example of how to initialize a server or client see examples in the repository.
<div class="warning">
Channels need to be obtained only **after** registering all replication components and remote messages/events.
</div>
## Replicon states
The crate updates the [`ServerState`] and [`ClientState`] based on the states of [`RenetServer`](renet::RenetServer)
and [`RenetClient`](renet::RenetServer) in [`PreUpdate`].
This means that states won't be updated in schedules like [`Startup`].
As a workaround, you can directly check if Renet's resources are present.
*/
use Duration;
pub use netcode;
pub use renet;
pub use steam;
pub use RepliconRenetClientPlugin;
pub use RepliconRenetServerPlugin;
use ;
use *;
use ;
/// Plugin group for all Replicon renet backend plugins.
///
/// Contains the following:
/// * [`RepliconRenetServerPlugin`] - with feature `server`.
/// * [`RepliconRenetClientPlugin`] - with feature `client`.
;
/// External trait for [`RepliconChannels`] to provide convenient conversion into renet channel configs.
/// Converts Replicon channels into renet channel configs.