ITADN

Revision 0.8.8

#31Pull Requestsinclairzx81 创建于 2024-08-13已合并
S
sinclairzx81commented
This PR adds a `.stats()` function to return current WebRTC network statistics. This is a synchronous function that can be called at relatively high frequency. The following is the API. ```typescript import { Network } from '@sinclair/smoke' const { WebRtc } = new Network({ ... }) const stats = WebRtc.stats() ``` This function will return an array of `WebRtcPeerStatistics` structures of the following form. ```typescript // ------------------------------------------------------------------ // WebRtcPeerStatistic // ------------------------------------------------------------------ export interface WebRtcPeerStatistic { /** The local address of this peer */ localAddress: string /** The remote address of this peer */ remoteAddress: string /** If this peer is making an offer */ makingOffer: boolean /** If this peer is ignoring offers */ ignoreOffer: boolean /** The number of bytes sent to this peer */ bytesSent: number /** The number of bytes received from this peer */ bytesReceived: number /** The number of send bytes being buffered for this peer */ bytesBuffered: number /** The number of data channels being managed by this peer */ channelCount: number } ``` --- Note: As of this PR, the `bytesReceived` and `bytesSent` totals are accumulated inside the `NetModule` (not inside the `WebRtcModule`). While the `bytesReceived` could technically be handled via the `WebRtcModule`, this update holds that all interactions with a channel (including subscribing to message events) should be handled exterior to the `WebRtcModule` (where the `WebRtcModule` is limited to peer connection establishment only, not interactions with channels or media on that connection).
合并状态:已合并 合并于 2024-08-13 关闭于 2024-08-13 0 条评论