davidliu

formatting

@@ -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
@@ -309,7 +308,7 @@ constructor( @@ -309,7 +308,7 @@ constructor(
309 } 308 }
310 } 309 }
311 310
312 - val request = LivekitRtc.SignalRequest.newBuilder() 311 + val request = LivekitRtc.SignalRequest.newBuilder()
313 .setTrackSetting(trackSettings) 312 .setTrackSetting(trackSettings)
314 .build() 313 .build()
315 314
@@ -321,13 +320,13 @@ constructor( @@ -321,13 +320,13 @@ constructor(
321 .addTrackSids(sid) 320 .addTrackSids(sid)
322 .setSubscribe(subscribe) 321 .setSubscribe(subscribe)
323 322
324 - val request = LivekitRtc.SignalRequest.newBuilder() 323 + val request = LivekitRtc.SignalRequest.newBuilder()
325 .setSubscription(subscription) 324 .setSubscription(subscription)
326 .build() 325 .build()
327 326
328 sendRequest(request) 327 sendRequest(request)
329 } 328 }
330 - 329 +
331 fun sendLeave() { 330 fun sendLeave() {
332 val request = LivekitRtc.SignalRequest.newBuilder() 331 val request = LivekitRtc.SignalRequest.newBuilder()
333 .setLeave(LivekitRtc.LeaveRequest.newBuilder().build()) 332 .setLeave(LivekitRtc.LeaveRequest.newBuilder().build())
@@ -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) {