@@ -26,6 +26,7 @@ import io.livekit.android.room.Room
26
26
import io.livekit.android.room.RoomListener
27
27
import io.livekit.android.util.LKLog
28
28
import io.livekit.android.util.LoggingLevel
29
+ import io.livekit.android.util.executeSuspendWithRetry
29
30
import timber.log.Timber
30
31
31
32
class LiveKit {
@@ -114,6 +115,7 @@ class LiveKit {
114
115
* Connect to a LiveKit room
115
116
* @param url URL to LiveKit server (i.e. ws://mylivekitdeploy.io)
116
117
* @param listener Listener to Room events. LiveKit interactions take place with these callbacks
118
+ * @param maxConnectRetry Int to set max connect retry.
117
119
*/
118
120
@Deprecated(" Use LiveKit.create and Room.connect instead. This is limited to max protocol 7." )
119
121
suspend fun connect (
@@ -124,6 +126,7 @@ class LiveKit {
124
126
roomOptions : RoomOptions = RoomOptions (),
125
127
listener : RoomListener ? = null,
126
128
overrides : LiveKitOverrides = LiveKitOverrides (),
129
+ maxConnectRetry : Int = 0
127
130
): Room {
128
131
val room = create(appContext, roomOptions, overrides)
129
132
@@ -132,7 +135,10 @@ class LiveKit {
132
135
val protocolVersion = maxOf(options.protocolVersion, ProtocolVersion .v7)
133
136
val connectOptions = options.copy(protocolVersion = protocolVersion)
134
137
135
- room.connect(url, token, connectOptions)
138
+ executeSuspendWithRetry(maxConnectRetry){
139
+ room.connect(url, token, connectOptions)
140
+ }
141
+
136
142
return room
137
143
}
138
144
}
0 commit comments