Optionaloptions: { timeoutDuration?: number }OptionaltimeoutDuration?: numberIt helps prevent the method from getting stuck indefinitely when fetching network statistics. It lets you set a maximum time for the operation, and if it takes longer than that, the method stops gracefully.
You can specify timeoutDuration in milliseconds. If it is not provided or is not an integer, the default timeout is set to 60,000 milliseconds (1 minute).
import { getNetworkStats } from "@videosdk.live/react-sdk";
try {
const options = { timeoutDuration: 45000 }; // Set a custom timeout of 45 seconds
const networkStats = await getNetworkStats(options);
console.log("Download Speed: ", networkStats["downloadSpeed"]); // will return value in Mb/s
console.log("Upload Speed: ", networkStats["uploadSpeed"]); // will return value in Mb/s
} catch(ex) {
console.log("Error in networkStats: ", ex);
}
Promisethat resolves with network speed statistics or rejects if the operation fails or exceeds the specified timeout.downloadSpeedanduploadSpeed, expressed in megabytes per second (MB/s).