mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-12 10:39:57 +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 clientConnection?: Channel;
|
||||||
private clientHeartbeat?: Channel;
|
private clientHeartbeat?: Channel;
|
||||||
private clientReceiver?: Channel;
|
private clientReceiver?: Channel;
|
||||||
private clientHeartbeatIntervalId?: NodeJS.Timer;
|
private clientHeartbeatIntervalId?: NodeJS.Timeout;
|
||||||
|
|
||||||
private isSessionCreated = false;
|
private isSessionCreated = false;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const NS_RECEIVER = "urn:x-cast:com.google.cast.receiver";
|
|||||||
export default class StatusListener extends EventEmitter {
|
export default class StatusListener extends EventEmitter {
|
||||||
private client: Client;
|
private client: Client;
|
||||||
private clientReceiver?: Channel;
|
private clientReceiver?: Channel;
|
||||||
private clientHeartbeatIntervalId?: number;
|
private clientHeartbeatIntervalId?: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private host: string
|
private host: string
|
||||||
@@ -27,7 +27,7 @@ export default class StatusListener extends EventEmitter {
|
|||||||
this.client.connect({ host, port }, this.onConnect.bind(this));
|
this.client.connect({ host, port }, this.onConnect.bind(this));
|
||||||
|
|
||||||
this.client.on("close", () => {
|
this.client.on("close", () => {
|
||||||
clearInterval(this.clientHeartbeatIntervalId);
|
clearInterval(this.clientHeartbeatIntervalId!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +80,6 @@ export default class StatusListener extends EventEmitter {
|
|||||||
|
|
||||||
this.clientHeartbeatIntervalId = setInterval(() => {
|
this.clientHeartbeatIntervalId = setInterval(() => {
|
||||||
clientHeartbeat.send({ type: "PING" });
|
clientHeartbeat.send({ type: "PING" });
|
||||||
});
|
}, 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export default new class ShimManager {
|
|||||||
private activeShims = new Set<Shim>();
|
private activeShims = new Set<Shim>();
|
||||||
|
|
||||||
public async init () {
|
public async init () {
|
||||||
await StatusManager.init();
|
|
||||||
await this.initStatusListeners();
|
await this.initStatusListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user