| | 1 | | using System; |
| | 2 | | using KernelCommunication; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.CRDT |
| | 6 | | { |
| | 7 | | public class BinaryMessageBridge : MonoBehaviour |
| | 8 | | { |
| | 9 | | [Serializable] |
| | 10 | | public class Message |
| | 11 | | { |
| | 12 | | public string sceneId; |
| | 13 | | public string data; |
| | 14 | | } |
| | 15 | |
|
| | 16 | | private KernelBinaryMessageProcessor binaryMessageProcessor; |
| | 17 | |
|
| | 18 | | public void BinaryMessage(string message) |
| | 19 | | { |
| 0 | 20 | | binaryMessageProcessor ??= new KernelBinaryMessageProcessor(Environment.i.world.sceneController); |
| | 21 | |
|
| 0 | 22 | | Message msg = JsonUtility.FromJson<Message>(message); |
| | 23 | |
|
| 0 | 24 | | byte[] bytes = Convert.FromBase64String(msg.data); |
| 0 | 25 | | string sceneId = msg.sceneId; |
| | 26 | |
|
| 0 | 27 | | binaryMessageProcessor.Process(sceneId, bytes); |
| 0 | 28 | | } |
| | 29 | | } |
| | 30 | | } |