aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.rs16
-rw-r--r--src/server.rs14
2 files changed, 13 insertions, 17 deletions
diff --git a/src/client.rs b/src/client.rs
index 306f010..2f7eda5 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -390,17 +390,14 @@ async fn connection_task(mut spawn_config: ConnectionSpawnConfig) {
.expect("Failed to create client endpoint");
endpoint.set_default_client_config(client_cfg);
- let new_connection = endpoint
+ let connection = endpoint
.connect(server_addr, &srv_host) // TODO Clean: error handling
.expect("Failed to connect: configuration error")
.await;
- match new_connection {
+ match connection {
Err(e) => error!("Error while connecting: {}", e),
- Ok(mut new_connection) => {
- info!(
- "Connected to {}",
- new_connection.connection.remote_address()
- );
+ Ok(connection) => {
+ info!("Connected to {}", connection.remote_address());
spawn_config
.to_sync_client
@@ -408,8 +405,7 @@ async fn connection_task(mut spawn_config: ConnectionSpawnConfig) {
.await
.expect("Failed to signal connection to sync client");
- let send = new_connection
- .connection
+ let send = connection
.open_uni()
.await
.expect("Failed to open send stream");
@@ -449,7 +445,7 @@ async fn connection_task(mut spawn_config: ConnectionSpawnConfig) {
trace!("New Stream listener forced to disconnected")
}
_ = async {
- while let Some(Ok(recv)) = new_connection.uni_streams.next().await {
+ while let Ok(recv)= connection.accept_uni().await {
let mut frame_recv = FramedRead::new(recv, LengthDelimitedCodec::new());
let from_server_sender = spawn_config.from_server_sender.clone();
diff --git a/src/server.rs b/src/server.rs
index ae7ae83..4500444 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -13,7 +13,7 @@ use bevy::prelude::*;
use bytes::Bytes;
use futures::sink::SinkExt;
use futures_util::StreamExt;
-use quinn::{Endpoint, NewConnection, ServerConfig};
+use quinn::{Endpoint, ServerConfig};
use serde::Deserialize;
use tokio::{
sync::{
@@ -404,14 +404,14 @@ async fn connections_listening_task(
let mut client_gen_id: ClientId = 0;
let mut client_id_mappings = HashMap::new();
- let (_endpoint, mut incoming) =
+ let endpoint =
Endpoint::server(server_config, server_addr).expect("Failed to create server endpoint");
// Start iterating over incoming connections/clients.
- while let Some(conn) = incoming.next().await {
- let mut new_connection: NewConnection =
- conn.await.expect("Failed to handle incoming connection");
- let connection = new_connection.connection;
+ while let Some(connecting) = endpoint.accept().await {
+ let connection = connecting
+ .await
+ .expect("Failed to handle incoming connection");
// Attribute an id to this client
client_gen_id += 1; // TODO Fix: Better id generation/check
@@ -505,7 +505,7 @@ async fn connections_listening_task(
}
_ = async {
// For each new stream opened by the client
- while let Some(Ok(recv)) = new_connection.uni_streams.next().await {
+ while let Ok(recv) = connection.accept_uni().await {
let mut frame_recv = FramedRead::new(recv, LengthDelimitedCodec::new());
// Spawn a task to receive data on this stream.