PaoloRotolo

Untitled

Apr 13th, 2021
420
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×