mirror of
https://github.com/haveno-dex/haveno-ts.git
synced 2025-07-05 12:04:44 -04:00
remove data callback listener
This commit is contained in:
parent
98a9e688e0
commit
0808e7ccd5
1 changed files with 7 additions and 5 deletions
|
@ -44,6 +44,11 @@ export default class HavenoClient {
|
||||||
// constants
|
// constants
|
||||||
static readonly _fullyInitializedMessage = "Application fully initialized";
|
static readonly _fullyInitializedMessage = "Application fully initialized";
|
||||||
static readonly _loginRequiredMessage = "Interactive login required";
|
static readonly _loginRequiredMessage = "Interactive login required";
|
||||||
|
onData = (data: any) => { // callback for grpc notifications
|
||||||
|
if (data instanceof NotificationMessage) {
|
||||||
|
for (const listener of this._notificationListeners) listener(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a client connected to a Haveno daemon.
|
* Construct a client connected to a Haveno daemon.
|
||||||
|
@ -1588,11 +1593,7 @@ export default class HavenoClient {
|
||||||
|
|
||||||
// send request to register client listener
|
// send request to register client listener
|
||||||
this._notificationStream = this._notificationsClient.registerNotificationListener(new RegisterNotificationListenerRequest(), {password: this._password})
|
this._notificationStream = this._notificationsClient.registerNotificationListener(new RegisterNotificationListenerRequest(), {password: this._password})
|
||||||
.on('data', (data) => {
|
.on('data', this.onData);
|
||||||
if (data instanceof NotificationMessage) {
|
|
||||||
for (const listener of this._notificationListeners) listener(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// periodically send keep alive requests // TODO (woodser): better way to keep notification stream alive?
|
// periodically send keep alive requests // TODO (woodser): better way to keep notification stream alive?
|
||||||
let firstRequest = true;
|
let firstRequest = true;
|
||||||
|
@ -1610,6 +1611,7 @@ export default class HavenoClient {
|
||||||
setTimeout(resolve, 1000); // TODO: call returns before listener registered
|
setTimeout(resolve, 1000); // TODO: call returns before listener registered
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
this._notificationStream!.removeListener('data', this.onData);
|
||||||
this._keepAliveLooper.stop();
|
this._keepAliveLooper.stop();
|
||||||
this._notificationStream!.cancel();
|
this._notificationStream!.cancel();
|
||||||
this._notificationStream = undefined;
|
this._notificationStream = undefined;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue