CallStats for iOS
Callstats 是用于 iOS 的 WebRTC 分析库。
入门指南
Cocoapods
pod 'Callstats'
创建 Callstats 对象
callstats = Callstats(
appID: appID, // Application ID from Callstats
localID: localID, // current user ID
deviceID: deviceID, // unique device ID
jwt: jwt, // jwt from server for authentication
username: username) // (Optional) user alias
发送事件
开始通话时,使用房间标识符调用 startSession
。
callstats.startSession(confID: room)
需要将这些事件转发到库中以便开始跟踪通话。将以下内容添加到您的 WebRTC RTCPeerConnectionDelegate
。例如:
func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceConnectionState) {
callstats.reportEvent(remoteUserID: peerId, event: CSIceConnectionChangeEvent(state: newState))
}
func peerConnection(_ peerConnection: RTCPeerConnection, didChange newState: RTCIceGatheringState) {
callstats.reportEvent(remoteUserID: peerId, event: CSIceGatheringChangeEvent(state: newState))
}
func peerConnection(_ peerConnection: RTCPeerConnection, didChange stateChanged: RTCSignalingState) {
callstats.reportEvent(remoteUserID: peerId, event: CSSignalingChangeEvent(state: stateChanged))
}
通话结束时
callstats.stopSession()
您可以在示例应用程序中查看如何发送更多事件。