Skip to content

Commit

Permalink
Added blocking call to Node.js client
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
markmandel committed Jul 29, 2019
1 parent a368366 commit 4717b2c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 14 additions & 1 deletion sdks/nodejs/src/agonesSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/Guides/Client SDKs/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}}

Expand Down
3 changes: 3 additions & 0 deletions test/sdk/nodejs/testSDKClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4717b2c

Please sign in to comment.