diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-06-20 12:37:31 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2022-06-20 18:38:03 +0200 |
commit | 1d6cfd52d2692160f347a16fa596dff18ee476bd (patch) | |
tree | af94a759c2e2ab8385cd8fc9bda7f2f07951d993 /docs | |
parent | 782b67c564d857c2dc388b743a1f360282481278 (diff) |
Add helper functions to print connection stats
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/Talkbuchet-cli.py | 20 | ||||
-rw-r--r-- | docs/Talkbuchet.js | 36 |
2 files changed, 56 insertions, 0 deletions
diff --git a/docs/Talkbuchet-cli.py b/docs/Talkbuchet-cli.py index 2d9e030ea..7816e3877 100644 --- a/docs/Talkbuchet-cli.py +++ b/docs/Talkbuchet-cli.py @@ -544,6 +544,8 @@ class Talkbuchet: window.setSentVideoStreamEnabled = setSentVideoStreamEnabled window.checkPublishersConnections = checkPublishersConnections window.checkSubscribersConnections = checkSubscribersConnections + window.printPublisherStats = printPublisherStats + window.printSubscriberStats = printSubscriberStats window.setCredentials = setCredentials window.setToken = setToken window.setPublishersAndSubscribersCount = setPublishersAndSubscribersCount @@ -661,6 +663,24 @@ class Talkbuchet: self.seleniumHelper.execute('checkSubscribersConnections()') + def printPublisherStats(self, publisherSessionId): + """ + Prints the stats of the given publisher connection. + + :param publisherSessionId: the session ID of the publisher. + """ + + self.seleniumHelper.executeAsync('await printPublisherStats(\'' + publisherSessionId + '\', true)') + + def printSubscriberStats(self, index): + """ + Prints the stats of the given subscriber connection. + + :param index: the index of the subscriber in the list of subscribers. + """ + + self.seleniumHelper.executeAsync('await printSubscriberStats(' + str(index) + ', true)') + def setPublishersAndSubscribersCount(self, publishersCount, subscribersPerPublisherCount): """ Sets the number of publishers and subscribers per publisher to use. diff --git a/docs/Talkbuchet.js b/docs/Talkbuchet.js index d7c238624..ec0293c7b 100644 --- a/docs/Talkbuchet.js +++ b/docs/Talkbuchet.js @@ -799,6 +799,42 @@ const checkSubscribersConnections = function() { console.info(' - Failed: ' + (iceConnectionStateCount['failed'] ?? 0)) } +const printPublisherStats = async function(publisherSessionId, stringify = false) { + if (!(publisherSessionId in publishers)) { + console.error('Invalid publisher session ID') + + return + } + + stats = await publishers[publisherSessionId].peerConnection.getStats() + + for (stat of stats.values()) { + if (stringify) { + console.info(JSON.stringify(stat)) + } else { + console.info(stat) + } + } +} + +const printSubscriberStats = async function(index, stringify = false) { + if (!(index in subscribers)) { + console.error('Index out of range') + + return + } + + stats = await subscribers[index].peerConnection.getStats() + + for (stat of stats.values()) { + if (stringify) { + console.info(JSON.stringify(stat)) + } else { + console.info(stat) + } + } +} + const setCredentials = function(userToSet, appTokenToSet) { user = userToSet appToken = appTokenToSet |