Advertisement
PaoloRotolo

Untitled

Apr 13th, 2021
888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.28 KB | None | 0 0
  1.     fun OnUnityMessage(value: String) {
  2.         if (value.startsWith("dm;")) {
  3.             val message = value.split(";")[1] // here
  4.             // IT'S A DIRECT MESSAGE
  5.             Timber.e("DM RECEIVED ${message}")
  6.  
  7.             if (message.startsWith("record=")) {
  8.                 // Recording is started
  9.                 val record = message.split("=")[1]
  10.                 setRecording(record)
  11.             }
  12.         }
  13.     }
  14.  
  15.     private fun setRecording(recordingJson: String) {
  16.         val recordingData = Gson().fromJson(recordingJson, RecordingVideocall::class.java)
  17.  
  18.         viewModel.registrationEnabled = when (recordingData.action) {
  19.             RecordingVideocall.ACTION_START -> {
  20.                 sendPrivateMessage("recordStarted")
  21.             }
  22.             RecordingVideocall.ACTION_STOP -> {
  23.                 sendPrivateMessage("recordStopped")
  24.             }
  25.             else -> false
  26.         }
  27.  
  28.         UnityPlayer.UnitySendMessage(
  29.             "ExternalCommunicator",
  30.             "NotifyRecording",
  31.             recordingJson)
  32.     }
  33.  
  34.     private fun sendPrivateMessage(message: String) {
  35.         Timber.e("Sending private message: $message")
  36.         UnityPlayer.UnitySendMessage(
  37.             "ExternalCommunicator", "DirectMessage", message
  38.         )
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement