att-client
Advanced tools
Comparing version 0.5.3-beta.2 to 0.5.3-beta.3
@@ -7,3 +7,3 @@ "use strict"; | ||
name: 'att-client', | ||
version: '0.5.3-beta.2' | ||
version: '0.5.3-beta.3' | ||
}; | ||
@@ -10,0 +10,0 @@ const SECOND = 1000; |
@@ -14,4 +14,2 @@ "use strict"; | ||
servers; | ||
keepAlive; | ||
missedHeartbeats; | ||
userId; | ||
@@ -23,4 +21,2 @@ constructor(client, group, member) { | ||
this.id = group.id; | ||
this.keepAlive = undefined; | ||
this.missedHeartbeats = 0; | ||
this.name = group.name ?? ''; | ||
@@ -152,20 +148,9 @@ this.permissions = this.getPermissions(group, member); | ||
async handleHeartbeat(status) { | ||
if (status.is_online) { | ||
this.missedHeartbeats = 0; | ||
clearInterval(this.keepAlive); | ||
const serverId = status.id; | ||
const server = await this.ensureServer(serverId); | ||
if (typeof server === 'undefined') { | ||
this.client.logger.error(`[GROUP-${this.id}] Server ${serverId} not found in group.`); | ||
return; | ||
} | ||
this.keepAlive = setInterval(() => { | ||
this.client.logger.info(`[GROUP-${this.id}] No heartbeat received for server ${serverId} (${server.name}) in the last ${this.client.config.serverHeartbeatInterval * ++this.missedHeartbeats} ms.`); | ||
if (this.missedHeartbeats >= this.client.config.maxMissedServerHeartbeats) { | ||
this.client.logger.info(`[GROUP-${this.id}] Maximum missed heartbeats reached for server ${serverId} (${server.name}). Closing connection.`); | ||
server.disconnect(); | ||
clearInterval(this.keepAlive); | ||
} | ||
}, this.client.config.serverHeartbeatInterval); | ||
const serverId = status.id; | ||
const server = await this.ensureServer(serverId); | ||
if (typeof server === 'undefined') { | ||
this.client.logger.error(`[GROUP-${this.id}] Server ${serverId} not found in group.`); | ||
return; | ||
} | ||
server.handleHeartbeat(status); | ||
this.manageServerConnection(status); | ||
@@ -194,3 +179,2 @@ } | ||
else if (server.status !== 'disconnected' && (!mayConnect || !isServerOnline)) { | ||
clearInterval(this.keepAlive); | ||
server.disconnect(); | ||
@@ -251,3 +235,2 @@ } | ||
async dispose() { | ||
clearInterval(this.keepAlive); | ||
this.removeServers(); | ||
@@ -254,0 +237,0 @@ await Promise.all([ |
@@ -16,2 +16,4 @@ "use strict"; | ||
connection; | ||
keepAlive; | ||
missedHeartbeats; | ||
constructor(group, server) { | ||
@@ -23,2 +25,4 @@ super(); | ||
this.id = server.id; | ||
this.keepAlive = undefined; | ||
this.missedHeartbeats = 0; | ||
this.name = server.name ?? group.name ?? ''; | ||
@@ -87,2 +91,3 @@ this.playability = server.playability; | ||
disconnect() { | ||
clearInterval(this.keepAlive); | ||
if (typeof this.connection === 'undefined') | ||
@@ -117,2 +122,15 @@ return; | ||
} | ||
handleHeartbeat(status) { | ||
clearInterval(this.keepAlive); | ||
this.missedHeartbeats = 0; | ||
if (status.is_online) { | ||
this.keepAlive = setInterval(() => { | ||
this.group.client.logger.info(`[SERVER-${this.id}] No heartbeat received in the last ${this.group.client.config.serverHeartbeatInterval * ++this.missedHeartbeats} ms.`); | ||
if (this.missedHeartbeats >= this.group.client.config.maxMissedServerHeartbeats) { | ||
this.group.client.logger.info(`[SERVER-${this.id}] Maximum missed heartbeats reached. Closing connection.`); | ||
this.disconnect(); | ||
} | ||
}, this.group.client.config.serverHeartbeatInterval); | ||
} | ||
} | ||
dispose() { | ||
@@ -119,0 +137,0 @@ this.disconnect(); |
import './Logger/index.js'; | ||
export const AGENT = { | ||
name: 'att-client', | ||
version: '0.5.3-beta.2' | ||
version: '0.5.3-beta.3' | ||
}; | ||
@@ -6,0 +6,0 @@ const SECOND = 1000; |
@@ -11,4 +11,2 @@ import { TypedEmitter } from '@mdingena/tiny-typed-emitter'; | ||
servers; | ||
keepAlive; | ||
missedHeartbeats; | ||
userId; | ||
@@ -20,4 +18,2 @@ constructor(client, group, member) { | ||
this.id = group.id; | ||
this.keepAlive = undefined; | ||
this.missedHeartbeats = 0; | ||
this.name = group.name ?? ''; | ||
@@ -149,20 +145,9 @@ this.permissions = this.getPermissions(group, member); | ||
async handleHeartbeat(status) { | ||
if (status.is_online) { | ||
this.missedHeartbeats = 0; | ||
clearInterval(this.keepAlive); | ||
const serverId = status.id; | ||
const server = await this.ensureServer(serverId); | ||
if (typeof server === 'undefined') { | ||
this.client.logger.error(`[GROUP-${this.id}] Server ${serverId} not found in group.`); | ||
return; | ||
} | ||
this.keepAlive = setInterval(() => { | ||
this.client.logger.info(`[GROUP-${this.id}] No heartbeat received for server ${serverId} (${server.name}) in the last ${this.client.config.serverHeartbeatInterval * ++this.missedHeartbeats} ms.`); | ||
if (this.missedHeartbeats >= this.client.config.maxMissedServerHeartbeats) { | ||
this.client.logger.info(`[GROUP-${this.id}] Maximum missed heartbeats reached for server ${serverId} (${server.name}). Closing connection.`); | ||
server.disconnect(); | ||
clearInterval(this.keepAlive); | ||
} | ||
}, this.client.config.serverHeartbeatInterval); | ||
const serverId = status.id; | ||
const server = await this.ensureServer(serverId); | ||
if (typeof server === 'undefined') { | ||
this.client.logger.error(`[GROUP-${this.id}] Server ${serverId} not found in group.`); | ||
return; | ||
} | ||
server.handleHeartbeat(status); | ||
this.manageServerConnection(status); | ||
@@ -191,3 +176,2 @@ } | ||
else if (server.status !== 'disconnected' && (!mayConnect || !isServerOnline)) { | ||
clearInterval(this.keepAlive); | ||
server.disconnect(); | ||
@@ -248,3 +232,2 @@ } | ||
async dispose() { | ||
clearInterval(this.keepAlive); | ||
this.removeServers(); | ||
@@ -251,0 +234,0 @@ await Promise.all([ |
@@ -13,2 +13,4 @@ import { TypedEmitter } from '@mdingena/tiny-typed-emitter'; | ||
connection; | ||
keepAlive; | ||
missedHeartbeats; | ||
constructor(group, server) { | ||
@@ -20,2 +22,4 @@ super(); | ||
this.id = server.id; | ||
this.keepAlive = undefined; | ||
this.missedHeartbeats = 0; | ||
this.name = server.name ?? group.name ?? ''; | ||
@@ -84,2 +88,3 @@ this.playability = server.playability; | ||
disconnect() { | ||
clearInterval(this.keepAlive); | ||
if (typeof this.connection === 'undefined') | ||
@@ -114,2 +119,15 @@ return; | ||
} | ||
handleHeartbeat(status) { | ||
clearInterval(this.keepAlive); | ||
this.missedHeartbeats = 0; | ||
if (status.is_online) { | ||
this.keepAlive = setInterval(() => { | ||
this.group.client.logger.info(`[SERVER-${this.id}] No heartbeat received in the last ${this.group.client.config.serverHeartbeatInterval * ++this.missedHeartbeats} ms.`); | ||
if (this.missedHeartbeats >= this.group.client.config.maxMissedServerHeartbeats) { | ||
this.group.client.logger.info(`[SERVER-${this.id}] Maximum missed heartbeats reached. Closing connection.`); | ||
this.disconnect(); | ||
} | ||
}, this.group.client.config.serverHeartbeatInterval); | ||
} | ||
} | ||
dispose() { | ||
@@ -116,0 +134,0 @@ this.disconnect(); |
@@ -23,4 +23,2 @@ import type { GroupInfo, GroupMemberInfo } from '../Api/schemas/index.js'; | ||
servers: Servers; | ||
private keepAlive; | ||
private missedHeartbeats; | ||
private userId; | ||
@@ -27,0 +25,0 @@ constructor(client: Client, group: GroupInfo, member: GroupMemberInfo); |
@@ -23,2 +23,4 @@ import type { ServerFleet, ServerInfo } from '../Api/index.js'; | ||
private connection?; | ||
private keepAlive; | ||
private missedHeartbeats; | ||
constructor(group: Group, server: ServerInfo); | ||
@@ -29,4 +31,5 @@ connect(): Promise<ServerConnection>; | ||
update(status: ServerInfo): void; | ||
handleHeartbeat(status: ServerInfo): void; | ||
dispose(): void; | ||
} | ||
export {}; |
{ | ||
"name": "att-client", | ||
"version": "0.5.3-beta.2", | ||
"version": "0.5.3-beta.3", | ||
"description": "Node bot library for A Township Tale, a VR game by Alta", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/mdingena/att-client#readme", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4123
189267