Merge branch 'imbris/ping-while-waiting-for-gamesync' into 'master'

Keep connection alive while waiting for initial sync

See merge request veloren/veloren!1898
This commit is contained in:
Imbris 2021-03-14 22:07:56 +00:00
commit 4e454d3215

View File

@ -244,6 +244,7 @@ impl Client {
ping_stream.send(PingMsg::Ping)?;
// Wait for initial sync
let mut ping_interval = tokio::time::interval(core::time::Duration::from_secs(1));
let (
state,
entity,
@ -255,7 +256,12 @@ impl Client {
recipe_book,
max_group_size,
client_timeout,
) = match register_stream.recv().await? {
) = match loop {
tokio::select! {
res = register_stream.recv() => break res?,
_ = ping_interval.tick() => ping_stream.send(PingMsg::Ping)?,
}
} {
ServerInit::GameSync {
entity_package,
time_of_day,