Account sync in action

This commit is contained in:
binwiederhier
2023-01-11 21:38:10 -05:00
parent 3dd8dd4288
commit fdee54f921
8 changed files with 118 additions and 32 deletions

View File

@@ -11,7 +11,7 @@ class ConnectionManager {
constructor() {
this.connections = new Map(); // ConnectionId -> Connection (hash, see below)
this.stateListener = null; // Fired when connection state changes
this.notificationListener = null; // Fired when new notifications arrive
this.messageListener = null; // Fired when new notifications arrive
}
registerStateListener(listener) {
@@ -22,12 +22,12 @@ class ConnectionManager {
this.stateListener = null;
}
registerNotificationListener(listener) {
this.notificationListener = listener;
registerMessageListener(listener) {
this.messageListener = listener;
}
resetNotificationListener() {
this.notificationListener = null;
resetMessageListener() {
this.messageListener = null;
}
/**
@@ -97,9 +97,9 @@ class ConnectionManager {
}
notificationReceived(subscriptionId, notification) {
if (this.notificationListener) {
if (this.messageListener) {
try {
this.notificationListener(subscriptionId, notification);
this.messageListener(subscriptionId, notification);
} catch (e) {
console.error(`[ConnectionManager] Error handling notification for ${subscriptionId}`, e);
}