pub async fn new(port: Option<u16>, keep_alive: Option<Duration>) -> Result<Self> {
        let addr: http::Uri = format!(
            "http://localhost:{}",
            port.unwrap_or_else(|| {
                env::var("AGONES_SDK_GRPC_PORT")
                    .ok()
                    .and_then(|s| s.parse().ok())
                    .unwrap_or(9357)
            })
        )
        .parse()?;

        let builder = tonic::transport::channel::Channel::builder(addr)
            .keep_alive_timeout(keep_alive.unwrap_or_else(|| Duration::from_secs(30)));

        let channel = builder.connect().await?;
        let mut client = SdkClient::new(channel.clone());
        let alpha = Alpha::new(channel);

        tokio::time::timeout(Duration::from_secs(30), async {
            let mut connect_interval = tokio::time::interval(Duration::from_millis(100));

            loop {
                connect_interval.tick().await;

                if client.get_game_server(empty()).await.is_ok() {
                    break;
                }
            }
        }).await?;

        Ok(Self {
            client,
            alpha,
        })
    }
/// Starts a new SDK instance, and connects to localhost on the port specified
/// or else falls back to the `AGONES_SDK_GRPC_PORT` environment variable,
/// or defaults to 9357.
///
/// # Errors
///
/// - The port specified in `AGONES_SDK_GRPC_PORT` can't be parsed as a `u16`.
/// - A connection cannot be established with an Agones SDK server
/// - The handshake takes longer than 30 seconds
Starts a new SDK instance, and connects to localhost on the port specified
or else falls back to the `AGONES_SDK_GRPC_PORT` environment variable,
or defaults to 9357.
Starts a new SDK instance and connects to localhost on the port specified or else falls back to the ` AGONES_SDK_GRPC_PORT ` environment variable or defaults to 9357 .
pub async fn new(port: Option<u16>, keep_alive: Option<Duration>) -> Result<Self> {
        let addr: http::Uri = format!(
            "http://localhost:{}",
            port.unwrap_or_else(|| {
                env::var("AGONES_SDK_GRPC_PORT")
                    .ok()
                    .and_then(|s| s.parse().ok())
                    .unwrap_or(9357)
            })
        )
        .parse()?;
        let builder = tonic::transport::channel::Channel::builder(addr)
            .keep_alive_timeout(keep_alive.unwrap_or_else(|| Duration::from_secs(30)));
        let channel = builder.connect().await?;
        let mut client = SdkClient::new(channel.clone());
        let alpha = Alpha::new(channel);
        tokio::time::timeout(Duration::from_secs(30), async {
            let mut connect_interval = tokio::time::interval(Duration::from_millis(100));
            loop {
                connect_interval.tick().await;
                if client.get_game_server(empty()).await.is_ok() {
                    break;
                }
            }
        }).await?;
        Ok(Self {
            client,
            alpha,
        })
    }
pub async fn new ( port : Option < u16 > , keep_alive : Option < Duration > ) -> Result < Self > { let addr : http :: Uri = format ! ( " " port unwrap_or_else ( { env var ( " " ) ok ( ) and_then ( s s parse ( ) ok ( ) ) unwrap_or ( 9357 ) } ) ) . parse ( ) ? ; let builder = tonic :: transport :: channel :: Channel :: builder ( addr ) . keep_alive_timeout ( keep_alive . unwrap_or_else ( | | Duration :: from_secs ( 30 ) ) ) ; let channel = builder . connect ( ) . await ? ; let mut client = SdkClient :: new ( channel . clone ( ) ) ; let alpha = Alpha :: new ( channel ) ; tokio :: time :: timeout ( Duration :: from_secs ( 30 ) , async { let mut connect_interval = tokio :: time :: interval ( Duration :: from_millis ( 100 ) ) ; loop { connect_interval . tick ( ) . await ; if client . get_game_server ( empty ( ) ) . await . is_ok ( ) { break ; } } } ) . await ? ; Ok ( Self { client , alpha , } ) }
Starts a new SDK instance, and connects to localhost on the port specified
or else falls back to the `AGONES_SDK_GRPC_PORT` environment variable,
or defaults to 9357.
Starts a new SDK instance and connects to localhost on the port specified or else falls back to the ` AGONES_SDK_GRPC_PORT ` environment variable or defaults to 9357 .
port
Option<u16>
keep_alive
Option<Duration>
port
Option<u16>
keep_alive
Option<Duration>
errors
The port specified in `AGONES_SDK_GRPC_PORT` can't be parsed as a `u16`.
A connection cannot be established with an Agones SDK server
The handshake takes longer than 30 seconds
The port specified in ` AGONES_SDK_GRPC_PORT ` can ' t be parsed as a ` u16 ` . A connection cannot be established with an Agones SDK server The handshake takes longer than 30 seconds