| | 1 | | using DCL; |
| | 2 | | using DCL.Helpers; |
| | 3 | | using DCL.Social.Friends; |
| | 4 | | using JetBrains.Annotations; |
| | 5 | | using System; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace MainScripts.DCL.Controllers.FriendsController |
| | 9 | | { |
| | 10 | |
|
| | 11 | | public class MatrixInitializationBridge : MonoBehaviour, IMatrixInitializationBridge |
| | 12 | | { |
| 0 | 13 | | public string AccessToken { get; private set; } |
| | 14 | |
|
| | 15 | | public event Action<string> OnReceiveMatrixAccessToken; |
| | 16 | |
|
| | 17 | | public static MatrixInitializationBridge GetOrCreate() |
| | 18 | | { |
| 423 | 19 | | var bridgeObj = SceneReferences.i?.bridgeGameObject; |
| | 20 | |
|
| 423 | 21 | | return bridgeObj == null |
| | 22 | | ? new GameObject("Bridges").AddComponent<MatrixInitializationBridge>() |
| | 23 | | : bridgeObj.GetOrCreateComponent<MatrixInitializationBridge>(); |
| | 24 | | } |
| | 25 | |
|
| | 26 | | [PublicAPI] |
| | 27 | | public void InitializeMatrix(string json) |
| | 28 | | { |
| 0 | 29 | | string token = JsonUtility.FromJson<MatrixInitializationMessage>(json).token; |
| 0 | 30 | | AccessToken = token; |
| 0 | 31 | | OnReceiveMatrixAccessToken?.Invoke(token); |
| 0 | 32 | | } |
| | 33 | | } |
| | 34 | | } |