1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-08-20 08:24:02 +02:00

Reconnect on failure, with backoff; Deduping notifications

This commit is contained in:
Philipp Heckel 2022-02-24 09:52:49 -05:00
parent 3fac1c3432
commit 1536201e9a
6 changed files with 62 additions and 45 deletions

View file

@ -14,10 +14,12 @@ export class ConnectionManager {
subscriptions.forEach((id, subscription) => {
const added = !this.connections.get(id)
if (added) {
const wsUrl = subscription.wsUrl();
const connection = new Connection(wsUrl, id, onNotification);
const baseUrl = subscription.baseUrl;
const topic = subscription.topic;
const since = 0;
const connection = new Connection(id, baseUrl, topic, since, onNotification);
this.connections.set(id, connection);
console.log(`[ConnectionManager] Starting new connection ${id} using URL ${wsUrl}`);
console.log(`[ConnectionManager] Starting new connection ${id}`);
connection.start();
}
});
@ -27,7 +29,7 @@ export class ConnectionManager {
console.log(`[ConnectionManager] Closing connection ${id}`);
const connection = this.connections.get(id);
this.connections.delete(id);
connection.cancel();
connection.close();
});
}
}