正在显示
1 个修改的文件
包含
11 行增加
和
11 行删除
| @@ -60,12 +60,12 @@ constructor( | @@ -60,12 +60,12 @@ constructor( | ||
| 60 | url: String, | 60 | url: String, |
| 61 | token: String, | 61 | token: String, |
| 62 | options: ConnectOptions = ConnectOptions(), | 62 | options: ConnectOptions = ConnectOptions(), |
| 63 | - ) : LivekitRtc.JoinResponse { | ||
| 64 | - val joinResponse = connect(url,token, options) | 63 | + ): LivekitRtc.JoinResponse { |
| 64 | + val joinResponse = connect(url, token, options) | ||
| 65 | return (joinResponse as Either.Left).value | 65 | return (joinResponse as Either.Left).value |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | - suspend fun reconnect(url: String, token: String){ | 68 | + suspend fun reconnect(url: String, token: String) { |
| 69 | connect( | 69 | connect( |
| 70 | url, | 70 | url, |
| 71 | token, | 71 | token, |
| @@ -78,7 +78,7 @@ constructor( | @@ -78,7 +78,7 @@ constructor( | ||
| 78 | url: String, | 78 | url: String, |
| 79 | token: String, | 79 | token: String, |
| 80 | options: ConnectOptions | 80 | options: ConnectOptions |
| 81 | - ) : Either<LivekitRtc.JoinResponse, Unit> { | 81 | + ): Either<LivekitRtc.JoinResponse, Unit> { |
| 82 | var wsUrlString = "$url/rtc" + | 82 | var wsUrlString = "$url/rtc" + |
| 83 | "?protocol=$PROTOCOL_VERSION" + | 83 | "?protocol=$PROTOCOL_VERSION" + |
| 84 | "&access_token=$token" + | 84 | "&access_token=$token" + |
| @@ -119,7 +119,7 @@ constructor( | @@ -119,7 +119,7 @@ constructor( | ||
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | @ExperimentalCoroutinesApi | 121 | @ExperimentalCoroutinesApi |
| 122 | - fun onReady(){ | 122 | + fun onReady() { |
| 123 | coroutineScope.launch { | 123 | coroutineScope.launch { |
| 124 | responseFlow.collect { | 124 | responseFlow.collect { |
| 125 | responseFlow.resetReplayCache() | 125 | responseFlow.resetReplayCache() |
| @@ -127,6 +127,7 @@ constructor( | @@ -127,6 +127,7 @@ constructor( | ||
| 127 | } | 127 | } |
| 128 | } | 128 | } |
| 129 | } | 129 | } |
| 130 | + | ||
| 130 | //--------------------------------- WebSocket Listener --------------------------------------// | 131 | //--------------------------------- WebSocket Listener --------------------------------------// |
| 131 | override fun onOpen(webSocket: WebSocket, response: Response) { | 132 | override fun onOpen(webSocket: WebSocket, response: Response) { |
| 132 | if (isReconnecting) { | 133 | if (isReconnecting) { |
| @@ -168,9 +169,7 @@ constructor( | @@ -168,9 +169,7 @@ constructor( | ||
| 168 | var reason: String? = null | 169 | var reason: String? = null |
| 169 | try { | 170 | try { |
| 170 | lastUrl?.let { | 171 | lastUrl?.let { |
| 171 | - val validationUrl = "http" + it. | ||
| 172 | - substring(2). | ||
| 173 | - replaceFirst("/rtc?", "/rtc/validate?") | 172 | + val validationUrl = "http" + it.substring(2).replaceFirst("/rtc?", "/rtc/validate?") |
| 174 | val request = Request.Builder().url(validationUrl).build() | 173 | val request = Request.Builder().url(validationUrl).build() |
| 175 | val resp = okHttpClient.newCall(request).execute() | 174 | val resp = okHttpClient.newCall(request).execute() |
| 176 | if (!resp.isSuccessful) { | 175 | if (!resp.isSuccessful) { |
| @@ -236,7 +235,7 @@ constructor( | @@ -236,7 +235,7 @@ constructor( | ||
| 236 | sendRequest(request) | 235 | sendRequest(request) |
| 237 | } | 236 | } |
| 238 | 237 | ||
| 239 | - fun sendCandidate(candidate: IceCandidate, target: LivekitRtc.SignalTarget){ | 238 | + fun sendCandidate(candidate: IceCandidate, target: LivekitRtc.SignalTarget) { |
| 240 | val iceCandidateJSON = IceCandidateJSON( | 239 | val iceCandidateJSON = IceCandidateJSON( |
| 241 | candidate = candidate.sdp, | 240 | candidate = candidate.sdp, |
| 242 | sdpMid = candidate.sdpMid, | 241 | sdpMid = candidate.sdpMid, |
| @@ -298,10 +297,10 @@ constructor( | @@ -298,10 +297,10 @@ constructor( | ||
| 298 | .addTrackSids(sid) | 297 | .addTrackSids(sid) |
| 299 | .setDisabled(disabled) | 298 | .setDisabled(disabled) |
| 300 | .apply { | 299 | .apply { |
| 301 | - if(videoDimensions != null) { | 300 | + if (videoDimensions != null) { |
| 302 | width = videoDimensions.width | 301 | width = videoDimensions.width |
| 303 | height = videoDimensions.height | 302 | height = videoDimensions.height |
| 304 | - } else if(videoQuality != null) { | 303 | + } else if (videoQuality != null) { |
| 305 | quality = videoQuality | 304 | quality = videoQuality |
| 306 | } else { | 305 | } else { |
| 307 | // default to HIGH | 306 | // default to HIGH |
| @@ -370,6 +369,7 @@ constructor( | @@ -370,6 +369,7 @@ constructor( | ||
| 370 | responseFlow.tryEmit(response) | 369 | responseFlow.tryEmit(response) |
| 371 | } | 370 | } |
| 372 | } | 371 | } |
| 372 | + | ||
| 373 | private fun handleSignalResponseImpl(response: LivekitRtc.SignalResponse) { | 373 | private fun handleSignalResponseImpl(response: LivekitRtc.SignalResponse) { |
| 374 | LKLog.v { "response: $response" } | 374 | LKLog.v { "response: $response" } |
| 375 | when (response.messageCase) { | 375 | when (response.messageCase) { |
-
请 注册 或 登录 后发表评论