diff --git a/sdks/nodejs/src/agonesSDK.js b/sdks/nodejs/src/agonesSDK.js index 13b9d7b316..7d2d47faff 100644 --- a/sdks/nodejs/src/agonesSDK.js +++ b/sdks/nodejs/src/agonesSDK.js @@ -23,7 +23,20 @@ class AgonesSDK { this.healthStream = undefined; this.emitters = []; } - async close(){ + + async connect() { + return new Promise((resolve, reject) => { + this.client.waitForReady(Date.now() + 30000, (error) => { + if (error) { + reject(error); + } else { + resolve(); + } + }) + }); + } + + async close() { if (this.healthStream !== undefined){ this.healthStream.destroy() } diff --git a/site/content/en/docs/Guides/Client SDKs/rust.md b/site/content/en/docs/Guides/Client SDKs/rust.md index f8a5fced58..0062c07416 100644 --- a/site/content/en/docs/Guides/Client SDKs/rust.md +++ b/site/content/en/docs/Guides/Client SDKs/rust.md @@ -51,7 +51,7 @@ if sdk.health().is_ok() { To mark the [game session as ready]({{< relref "_index.md#ready" >}}) call `sdk.ready()`. ```rust -if sdk.ready()? +sdk.ready()?; ``` {{% /feature %}} diff --git a/test/sdk/nodejs/testSDKClient.js b/test/sdk/nodejs/testSDKClient.js index c99bf10431..e7d75120bc 100644 --- a/test/sdk/nodejs/testSDKClient.js +++ b/test/sdk/nodejs/testSDKClient.js @@ -18,6 +18,9 @@ const agonesSDK = new AgonesSDK(); const connect = async function() { var UID = "" try { + console.log("attempting to connect"); + await agonesSDK.connect(); + console.log("connected!"); var once = true; agonesSDK.watchGameServer((result) => { console.log("watch", result);