Skip to content

Commit

Permalink
fix self hosting
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed Jun 21, 2024
1 parent cd8589e commit c2bc9b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 2 additions & 7 deletions apps/networked_physics_demo/client/src/netcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ fn apply_queued_commands(
/// Other plugins create this when they want to connect to a manager.
#[derive(Debug, Event, Eq, PartialEq)]
pub struct ConnectToManagerRequest {
/// The URL of the manager to connect to. If `None`, locally host.
pub manager_url: Option<Url>,
/// The URL of the manager to connect to.
pub manager_url: Url,
}

/// Produced in response to [`ConnectToManagerRequest`].
Expand All @@ -94,13 +94,8 @@ pub struct ConnectToManagerResponse(pub Result<()>);
fn handle_connect_to_manager_evt(
command_queue: Res<CommandQueueChannel>,
mut request: EventReader<ConnectToManagerRequest>,
mut response: EventWriter<ConnectToManagerResponse>,
) {
for ConnectToManagerRequest { manager_url } in request.read() {
let Some(manager_url) = manager_url else {
response.send(ConnectToManagerResponse(Ok(())));
continue;
};
let manager_url = manager_url.to_owned();
let tx = command_queue.tx.clone();
let pool = IoTaskPool::get();
Expand Down
9 changes: 8 additions & 1 deletion apps/networked_physics_demo/client/src/title_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ mod ui {
.then(|| manager_url.parse())
.transpose()
{
Ok(parsed_manager_url) => {
Ok(Some(parsed_manager_url)) => {
evw.send(ConnectToManagerRequest {
manager_url: parsed_manager_url,
});
Expand All @@ -187,6 +187,13 @@ mod ui {
}
.into();
}
Ok(None) => {
// Locally host
evw.send(ConnectToInstanceRequest {
instance_url: None,
});
return JoinInstance::WaitingForConnection.into();
}
Err(_parse_err) => {
error_msg.clear();
error_msg.push_str("Invalid URL");
Expand Down

0 comments on commit c2bc9b4

Please sign in to comment.