Skip to content

Commit

Permalink
Trying to make a connect() function for nodejs.
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
markmandel committed Jul 28, 2019
1 parent a368366 commit 7faca63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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(30000, (error) => {
if (error) {
reject(error);
} else {
resolve();
}
})
});
}

async close() {
if (this.healthStream !== undefined){
this.healthStream.destroy()
}
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 7faca63

Please sign in to comment.