davidliu

fix npe in sync state

@@ -762,12 +762,15 @@ internal constructor( @@ -762,12 +762,15 @@ internal constructor(
762 .build() 762 .build()
763 } 763 }
764 764
765 - val syncState = LivekitRtc.SyncState.newBuilder()  
766 - .setAnswer(answer)  
767 - .setSubscription(subscription)  
768 - .addAllPublishTracks(publishedTracks)  
769 - .addAllDataChannels(dataChannelInfos)  
770 - .build() 765 + val syncState = with(LivekitRtc.SyncState.newBuilder()) {
  766 + if (answer != null) {
  767 + setAnswer(answer)
  768 + }
  769 + setSubscription(subscription)
  770 + addAllPublishTracks(publishedTracks)
  771 + addAllDataChannels(dataChannelInfos)
  772 + build()
  773 + }
771 774
772 client.sendSyncState(syncState) 775 client.sendSyncState(syncState)
773 } 776 }