aboutsummaryrefslogtreecommitdiff
path: root/examples/breakout
diff options
context:
space:
mode:
Diffstat (limited to 'examples/breakout')
-rw-r--r--examples/breakout/breakout.rs3
-rw-r--r--examples/breakout/client.rs10
-rw-r--r--examples/breakout/server.rs20
3 files changed, 16 insertions, 17 deletions
diff --git a/examples/breakout/breakout.rs b/examples/breakout/breakout.rs
index e57e2d7..31fcf01 100644
--- a/examples/breakout/breakout.rs
+++ b/examples/breakout/breakout.rs
@@ -1,6 +1,8 @@
//! A simplified implementation of the classic game "Breakout".
//! => Original example by Bevy, modified for Bevy Quinnet to add a 2 players versus mode.
+use std::net::{IpAddr, Ipv4Addr};
+
use bevy::{ecs::schedule::ShouldRun, prelude::*, time::FixedTimestep};
use bevy_quinnet::{
client::QuinnetClientPlugin,
@@ -13,6 +15,7 @@ mod protocol;
mod server;
const SERVER_HOST: &str = "127.0.0.1";
+const LOCAL_BIND_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
const SERVER_PORT: u16 = 6000;
// Defines the amount of time that should elapse between each physics step.
diff --git a/examples/breakout/client.rs b/examples/breakout/client.rs
index 33873d3..be4435a 100644
--- a/examples/breakout/client.rs
+++ b/examples/breakout/client.rs
@@ -24,7 +24,8 @@ use bevy_quinnet::{
use crate::{
protocol::{ClientMessage, PaddleInput, ServerMessage},
BrickId, CollisionEvent, CollisionSound, GameState, Score, Velocity, WallLocation, BALL_SIZE,
- BALL_SPEED, BRICK_SIZE, GAP_BETWEEN_BRICKS, PADDLE_SIZE, SERVER_HOST, SERVER_PORT, TIME_STEP,
+ BALL_SPEED, BRICK_SIZE, GAP_BETWEEN_BRICKS, LOCAL_BIND_IP, PADDLE_SIZE, SERVER_HOST,
+ SERVER_PORT, TIME_STEP,
};
const SCOREBOARD_FONT_SIZE: f32 = 40.0;
@@ -91,14 +92,13 @@ struct WallBundle {
#[bundle]
sprite_bundle: SpriteBundle,
}
-
pub(crate) fn start_connection(mut client: ResMut<Client>) {
client
.open_connection(
- ConnectionConfiguration::new(
- SERVER_HOST.to_string(),
+ ConnectionConfiguration::from_ips(
+ SERVER_HOST.parse().unwrap(),
SERVER_PORT,
- "0.0.0.0".to_string(),
+ LOCAL_BIND_IP,
0,
),
CertificateVerificationMode::SkipVerification,
diff --git a/examples/breakout/server.rs b/examples/breakout/server.rs
index 4164f7e..f2389bd 100644
--- a/examples/breakout/server.rs
+++ b/examples/breakout/server.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use std::{collections::HashMap};
use bevy::{
prelude::{
@@ -9,9 +9,7 @@ use bevy::{
transform::TransformBundle,
};
use bevy_quinnet::{
- server::{
- certificate::CertificateRetrievalMode, ConnectionEvent, Server, ServerConfigurationData,
- },
+ server::{certificate::CertificateRetrievalMode, ConnectionEvent, Server, ServerConfiguration},
shared::{channel::ChannelId, ClientId},
};
@@ -19,8 +17,8 @@ use crate::{
protocol::{ClientMessage, PaddleInput, ServerMessage},
BrickId, Velocity, WallLocation, BALL_SIZE, BALL_SPEED, BOTTOM_WALL, BRICK_SIZE,
GAP_BETWEEN_BRICKS, GAP_BETWEEN_BRICKS_AND_SIDES, GAP_BETWEEN_PADDLE_AND_BRICKS,
- GAP_BETWEEN_PADDLE_AND_FLOOR, LEFT_WALL, PADDLE_PADDING, PADDLE_SIZE, PADDLE_SPEED, RIGHT_WALL,
- SERVER_HOST, SERVER_PORT, TIME_STEP, TOP_WALL, WALL_THICKNESS,
+ GAP_BETWEEN_PADDLE_AND_FLOOR, LEFT_WALL, LOCAL_BIND_IP, PADDLE_PADDING, PADDLE_SIZE,
+ PADDLE_SPEED, RIGHT_WALL, SERVER_HOST, SERVER_PORT, TIME_STEP, TOP_WALL, WALL_THICKNESS,
};
const GAP_BETWEEN_PADDLE_AND_BALL: f32 = 35.;
@@ -81,12 +79,10 @@ struct WallBundle {
pub(crate) fn start_listening(mut server: ResMut<Server>) {
server
.start_endpoint(
- ServerConfigurationData::new(
- SERVER_HOST.to_string(),
- SERVER_PORT,
- "0.0.0.0".to_string(),
- ),
- CertificateRetrievalMode::GenerateSelfSigned,
+ ServerConfiguration::from_ip(LOCAL_BIND_IP, SERVER_PORT),
+ CertificateRetrievalMode::GenerateSelfSigned {
+ server_hostname: SERVER_HOST.to_string(),
+ },
)
.unwrap();
}