-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #931 from AmbientRun/randomly-generated-ids
Randomly generated IDs
- Loading branch information
Showing
151 changed files
with
961 additions
and
649 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,6 +249,7 @@ jobs: | |
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: dtolnay/rust-toolchain@stable | ||
- run: rustup target add --toolchain stable wasm32-wasi | ||
- uses: actions/checkout@v3 | ||
- name: Rust cache | ||
uses: Leafwing-Studios/[email protected] | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use ambient_native_std::{ | ||
asset_cache::{AssetCache, SyncAssetKeyExt}, | ||
download_asset::ReqwestClientKey, | ||
}; | ||
use ambient_network::native::client::ResolvedAddr; | ||
use clap::Parser; | ||
|
||
use crate::{client, server::QUIC_INTERFACE_PORT}; | ||
|
||
use super::ClientCli; | ||
|
||
#[derive(Parser, Clone, Debug)] | ||
/// Join a multiplayer session | ||
pub struct Join { | ||
#[command(flatten)] | ||
pub client: ClientCli, | ||
/// The server to connect to; defaults to localhost | ||
pub host: Option<String>, | ||
} | ||
|
||
pub fn handle(args: &Join, rt: &tokio::runtime::Runtime, assets: AssetCache) -> anyhow::Result<()> { | ||
let assets_ref = &assets; | ||
let server_addr = rt.block_on(async move { | ||
let Some(mut host) = args.host.as_ref().cloned() else { | ||
return Ok(ResolvedAddr::localhost_with_port(QUIC_INTERFACE_PORT)); | ||
}; | ||
|
||
if host.starts_with("http://") || host.starts_with("https://") { | ||
tracing::info!("NOTE: Joining server by http url is still experimental and can be removed without warning."); | ||
|
||
let reqwest = &ReqwestClientKey.get(assets_ref); | ||
host = reqwest.get(host).send().await?.text().await?; | ||
|
||
if host.is_empty() { | ||
anyhow::bail!("Failed to resolve host"); | ||
} | ||
} | ||
if !host.contains(':') { | ||
host = format!("{host}:{QUIC_INTERFACE_PORT}"); | ||
} | ||
ResolvedAddr::lookup_host(&host).await | ||
})?; | ||
client::run(rt, assets, server_addr, &args.client, None) | ||
} |
Oops, something went wrong.