mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-09 09:09:58 +00:00
Fix CPU usage issue with 0-interval timer (fixes #73)
This commit is contained in:
@@ -23,7 +23,7 @@ export default class Session {
|
||||
private clientConnection?: Channel;
|
||||
private clientHeartbeat?: Channel;
|
||||
private clientReceiver?: Channel;
|
||||
private clientHeartbeatIntervalId?: NodeJS.Timer;
|
||||
private clientHeartbeatIntervalId?: NodeJS.Timeout;
|
||||
|
||||
private isSessionCreated = false;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const NS_RECEIVER = "urn:x-cast:com.google.cast.receiver";
|
||||
export default class StatusListener extends EventEmitter {
|
||||
private client: Client;
|
||||
private clientReceiver?: Channel;
|
||||
private clientHeartbeatIntervalId?: number;
|
||||
private clientHeartbeatIntervalId?: NodeJS.Timeout;
|
||||
|
||||
constructor (
|
||||
private host: string
|
||||
@@ -27,7 +27,7 @@ export default class StatusListener extends EventEmitter {
|
||||
this.client.connect({ host, port }, this.onConnect.bind(this));
|
||||
|
||||
this.client.on("close", () => {
|
||||
clearInterval(this.clientHeartbeatIntervalId);
|
||||
clearInterval(this.clientHeartbeatIntervalId!);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,6 +80,6 @@ export default class StatusListener extends EventEmitter {
|
||||
|
||||
this.clientHeartbeatIntervalId = setInterval(() => {
|
||||
clientHeartbeat.send({ type: "PING" });
|
||||
});
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ export default new class ShimManager {
|
||||
private activeShims = new Set<Shim>();
|
||||
|
||||
public async init () {
|
||||
await StatusManager.init();
|
||||
await this.initStatusListeners();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user