-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdisposeXboxSmartGlass.ts
More file actions
29 lines (25 loc) · 969 Bytes
/
disposeXboxSmartGlass.ts
File metadata and controls
29 lines (25 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
* ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
* Only call `xboxSmartGlass.dispose()` when you are completely done with it
* and all Xbox instances. It cannot be revived. And since xboxSmartGlass is a singleton
* you cannot make a new one.
*
* This should only be called in order to cleanly shutdown your NodeJS process.
*
* Behavior of xboxSmartGlass and all Xbox instances is undefined after being disposed.
*/
import xboxSmartGlass from "../src";
// Start listening for Xbox consoles, just to demonstrate
// that the process will cleanly exit once disposed.
xboxSmartGlass.startDiscovery();
// Emits an Xbox console every time a discovery response is received.
xboxSmartGlass.on("discovery", async (xbox) => {
console.log("Received Xbox discovery response!");
});
xboxSmartGlass.on("disposed", () => {
console.log("XboxSmartGlass has been disposed!");
console.log("You can now safely exit.");
});
setTimeout(() => {
xboxSmartGlass.dispose();
}, 5000);