diff --git a/lib/Bot.ts b/lib/Bot.ts index 57fcdda..b61e198 100644 --- a/lib/Bot.ts +++ b/lib/Bot.ts @@ -364,6 +364,18 @@ export class Bot this.ping = setInterval(async() => { + const now = new Date().getTime(); + if (now - this.lastSuccessfulPing > 120 * 1000) + { + if (this.ping !== null) + { + clearInterval(this.ping); + this.ping = null; + this.disconnected(false, 'Disconnected from the simulator'); + } + return; + } + this.pingNumber++; if (this.pingNumber % 12 === 0 && this.stay) { @@ -418,7 +430,6 @@ export class Bot // No action needed }).catch(() => { - console.error('Timeout waiting for ping from the simulator - possible disconnection') }); diff --git a/package.json b/package.json index 250c8b4..59c6d2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@caspertech/node-metaverse", - "version": "0.7.29", + "version": "0.7.40", "description": "A node.js interface for Second Life.", "main": "dist/lib/index.js", "types": "dist/lib/index.d.ts",