adding call states based on connection

This commit is contained in:
talksik
2021-12-30 05:01:48 -08:00
parent 57c9b2dd46
commit 2d7c8e5904
2 changed files with 33 additions and 2 deletions
@@ -29,6 +29,33 @@ struct ConvoFooterView: View {
.font(.footnote)
.foregroundColor(NirvanaColor.light)
switch self.convoVM.connectionState {
case .connecting:
Label("connecting", systemImage: "chart.bar")
.foregroundColor(Color.orange)
.font(.caption)
case .connected:
Label("connected", systemImage: "chart.bar.fill")
.foregroundColor(Color.green)
.font(.caption)
case .reconnecting:
Label("reconnecting", systemImage: "chart.bar")
.foregroundColor(Color.orange)
.font(.caption)
case .failed:
Label("failed", systemImage: "chart.bar")
.foregroundColor(Color.red)
.font(.caption)
case .disconnected:
Label("disconnected", systemImage: "chart.bar")
.foregroundColor(Color.red)
.font(.caption)
default:
Label("disconnected", systemImage: "chart.bar")
.foregroundColor(Color.red)
.font(.caption)
}
Text(self.convoRelativeTime)
.font(.caption2)
.foregroundColor(.gray)
@@ -8,11 +8,11 @@
import Foundation
import AgoraRtcKit
class ConvoViewModel: NSObject, ObservableObject {
private var testingUIMode = true
@Published var selectedConvoId:String? = nil
@Published var connectionState: AgoraConnectionStateType? = nil
let firestoreService = FirestoreService()
@@ -137,9 +137,13 @@ extension ConvoViewModel {
}
extension ConvoViewModel: AgoraRtcEngineDelegate {
func rtcEngine(_ engine: AgoraRtcEngineKit, connectionChangedTo state: AgoraConnectionStateType, reason: AgoraConnectionChangedReason) {
self.connectionState = state
}
func rtcEngine(_ engine: AgoraRtcEngineKit, didJoinChannel channel: String, withUid uid: UInt, elapsed: Int) {
print("I did join channel")
// set my user status to in convo
// leave channel if it's just me