diff options
author | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-16 17:18:23 +0100 |
---|---|---|
committer | Henauxg <19689618+Henauxg@users.noreply.github.com> | 2022-11-16 17:18:23 +0100 |
commit | ee8fdbe772d7b81070a34fc9a4e722d18c3fe2af (patch) | |
tree | 55d50cc0ffefa31aea8bb9c26e189544637a3665 /examples | |
parent | ee4128777bc5e2204e1a36fb3149ba752de9e58e (diff) |
[examples] Update examples to use single_mut()
Diffstat (limited to 'examples')
-rw-r--r-- | examples/breakout/client.rs | 4 | ||||
-rw-r--r-- | examples/chat/client.rs | 19 | ||||
-rw-r--r-- | examples/chat/server.rs | 6 |
3 files changed, 10 insertions, 19 deletions
diff --git a/examples/breakout/client.rs b/examples/breakout/client.rs index ecc694d..edb0cef 100644 --- a/examples/breakout/client.rs +++ b/examples/breakout/client.rs @@ -200,7 +200,7 @@ pub(crate) fn handle_server_messages( mut scoreboard: ResMut<Scoreboard>, mut collision_events: EventWriter<CollisionEvent>, ) { - let mut connection = connection.get_single_mut().unwrap(); + let mut connection = connection.single_mut(); while let Ok(Some(message)) = connection.receive_message::<ServerMessage>() { match message { ServerMessage::InitClient { client_id } => { @@ -302,7 +302,7 @@ pub(crate) fn move_paddle( } if local.current_input != paddle_input { - let connection = connection.get_single_mut().unwrap(); + let connection = connection.single_mut(); connection .send_message(ClientMessage::PaddleInput { input: paddle_input.clone(), diff --git a/examples/chat/client.rs b/examples/chat/client.rs index dceaf23..6e5005b 100644 --- a/examples/chat/client.rs +++ b/examples/chat/client.rs @@ -14,8 +14,8 @@ use bevy::{ }; use bevy_quinnet::{ client::{ - certificate::{CertificateVerificationMode, TrustOnFirstUseConfig}, - Client, Connection, ConnectionConfiguration, ConnectionEvent, QuinnetClientPlugin, + certificate::CertificateVerificationMode, Client, Connection, ConnectionConfiguration, + ConnectionEvent, QuinnetClientPlugin, }, ClientId, }; @@ -37,7 +37,7 @@ struct TerminalReceiver(mpsc::Receiver<String>); pub fn on_app_exit(app_exit_events: EventReader<AppExit>, mut connection: Query<&Connection>) { if !app_exit_events.is_empty() { - let connection = connection.get_single_mut().unwrap(); + let connection = connection.single_mut(); connection .send_message(ClientMessage::Disconnect {}) .unwrap(); @@ -47,7 +47,7 @@ pub fn on_app_exit(app_exit_events: EventReader<AppExit>, mut connection: Query< } fn handle_server_messages(mut users: ResMut<Users>, mut connection: Query<&mut Connection>) { - let mut connection = connection.get_single_mut().unwrap(); + let mut connection = connection.single_mut(); while let Ok(Some(message)) = connection.receive_message::<ServerMessage>() { match message { ServerMessage::ClientConnected { @@ -89,7 +89,7 @@ fn handle_terminal_messages( mut app_exit_events: EventWriter<AppExit>, mut connection: Query<&Connection>, ) { - let connection = connection.get_single_mut().unwrap(); + let connection = connection.single_mut(); while let Ok(message) = terminal_messages.try_recv() { if message == "quit" { app_exit_events.send(AppExit); @@ -119,12 +119,7 @@ fn start_connection(mut commands: Commands, client: ResMut<Client>) { client.spawn_connection( &mut commands, ConnectionConfiguration::new("127.0.0.1".to_string(), 6000, "0.0.0.0".to_string(), 0), - CertificateVerificationMode::TrustOnFirstUse(TrustOnFirstUseConfig { - known_hosts: bevy_quinnet::client::certificate::KnownHosts::HostsFile( - "my_own_hosts_file".to_string(), - ), - ..Default::default() - }), + CertificateVerificationMode::SkipVerification, ); // You can already send message(s) even before being connected, they will be buffered. In this example we will wait for a ConnectionEvent. @@ -145,7 +140,7 @@ fn handle_client_events( println!("--- Joining with name: {}", username); println!("--- Type 'quit' to disconnect"); - let connection = connection.get_single_mut().unwrap(); + let connection = connection.single_mut(); connection .send_message(ClientMessage::Join { name: username }) .unwrap(); diff --git a/examples/chat/server.rs b/examples/chat/server.rs index d9fbc02..facaefa 100644 --- a/examples/chat/server.rs +++ b/examples/chat/server.rs @@ -114,11 +114,7 @@ fn start_listening(mut server: ResMut<Server>) { server .start( ServerConfigurationData::new("127.0.0.1".to_string(), 6000, "0.0.0.0".to_string()), - CertificateRetrievalMode::LoadFromFileOrGenerateSelfSigned { - cert_file: "cert.pem".to_string(), - key_file: "key.pem".to_string(), - save_on_disk: true, - }, + CertificateRetrievalMode::GenerateSelfSigned, ) .unwrap(); } |