< Summary

Class:DCL.Interface.WebInterfaceUUIDEvent[TPayload]
Assembly:WebInterface
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs
Covered lines:1
Uncovered lines:0
Coverable lines:1
Total lines:1930
Line coverage:100% (1 of 1)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
UUIDEvent()0%110100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/WebInterface/Interface.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using DCL.CameraTool;
 4using DCL.Models;
 5using Newtonsoft.Json;
 6using UnityEngine;
 7using UnityEngine.Serialization;
 8using Ray = UnityEngine.Ray;
 9
 10#if UNITY_WEBGL && !UNITY_EDITOR
 11using System.Runtime.InteropServices;
 12#endif
 13
 14namespace DCL.Interface
 15{
 16    /**
 17     * This class contains the outgoing interface of Decentraland.
 18     * You must call those functions to interact with the WebInterface.
 19     *
 20     * The messages comming from the WebInterface instead, are reported directly to
 21     * the handler GameObject by name.
 22     */
 23    public static class WebInterface
 24    {
 25        public static bool VERBOSE = false;
 26
 27        [System.Serializable]
 28        public class ReportPositionPayload
 29        {
 30            /** Camera position, world space */
 31            public Vector3 position;
 32
 33            /** Character rotation */
 34            public Quaternion rotation;
 35
 36            /** Camera rotation */
 37            public Quaternion cameraRotation;
 38
 39            /** Camera height, relative to the feet of the avatar or ground */
 40            public float playerHeight;
 41
 42            public Vector3 mousePosition;
 43
 44            public string id;
 45        }
 46
 47        [System.Serializable]
 48        public abstract class ControlEvent
 49        {
 50            public string eventType;
 51        }
 52
 53        public abstract class ControlEvent<T> : ControlEvent
 54        {
 55            public T payload;
 56
 57            protected ControlEvent(string eventType, T payload)
 58            {
 59                this.eventType = eventType;
 60                this.payload = payload;
 61            }
 62        }
 63
 64        [System.Serializable]
 65        public class SceneReady : ControlEvent<SceneReady.Payload>
 66        {
 67
 68            public SceneReady(int sceneNumber) : base("SceneReady", new Payload() { sceneNumber = sceneNumber }) { }
 69
 70            [System.Serializable]
 71            public class Payload
 72            {
 73                public int sceneNumber;
 74            }
 75        }
 76
 77        [System.Serializable]
 78        public class ActivateRenderingACK : ControlEvent<object>
 79        {
 80            public ActivateRenderingACK() : base("ActivateRenderingACK", null) { }
 81        }
 82
 83        [System.Serializable]
 84        public class DeactivateRenderingACK : ControlEvent<object>
 85        {
 86            public DeactivateRenderingACK() : base("DeactivateRenderingACK", null) { }
 87        }
 88
 89        [System.Serializable]
 90        public class SceneEvent<T>
 91        {
 92            public int sceneNumber;
 93            public string eventType;
 94            public T payload;
 95        }
 96
 97        [System.Serializable]
 98        public class AllScenesEvent<T>
 99        {
 100            public string eventType;
 101            public T payload;
 102        }
 103
 104        [System.Serializable]
 105        public class UUIDEvent<TPayload>
 106            where TPayload : class, new()
 107        {
 108            public string uuid;
 119109            public TPayload payload = new TPayload();
 110        }
 111
 112        public enum ACTION_BUTTON
 113        {
 114            POINTER = 0,
 115            PRIMARY = 1,
 116            SECONDARY = 2,
 117            ANY = 3,
 118            FORWARD = 4,
 119            BACKWARD = 5,
 120            RIGHT = 6,
 121            LEFT = 7,
 122            JUMP = 8,
 123            WALK = 9,
 124            ACTION_3 = 10,
 125            ACTION_4 = 11,
 126            ACTION_5 = 12,
 127            ACTION_6 = 13
 128        }
 129
 130        [System.Serializable]
 131        public class OnClickEvent : UUIDEvent<OnClickEventPayload> { };
 132
 133        [System.Serializable]
 134        public class CameraModePayload
 135        {
 136            public CameraMode.ModeId cameraMode;
 137        };
 138
 139        [System.Serializable]
 140        public class Web3UseResponsePayload
 141        {
 142            public string id;
 143            public bool result;
 144        };
 145
 146        [System.Serializable]
 147        public class IdleStateChangedPayload
 148        {
 149            public bool isIdle;
 150        };
 151
 152        [System.Serializable]
 153        public class OnPointerDownEvent : UUIDEvent<OnPointerEventPayload> { };
 154
 155        [System.Serializable]
 156        public class OnGlobalPointerEvent
 157        {
 158            public OnGlobalPointerEventPayload payload = new OnGlobalPointerEventPayload();
 159        };
 160
 161        [System.Serializable]
 162        public class OnPointerUpEvent : UUIDEvent<OnPointerEventPayload> { };
 163
 164        [System.Serializable]
 165        private class OnTextSubmitEvent : UUIDEvent<OnTextSubmitEventPayload> { };
 166
 167        [System.Serializable]
 168        private class OnTextInputChangeEvent : UUIDEvent<OnTextInputChangeEventPayload> { };
 169
 170        [System.Serializable]
 171        private class OnTextInputChangeTextEvent : UUIDEvent<OnTextInputChangeTextEventPayload> { };
 172
 173        [System.Serializable]
 174        private class OnScrollChangeEvent : UUIDEvent<OnScrollChangeEventPayload> { };
 175
 176        [System.Serializable]
 177        private class OnFocusEvent : UUIDEvent<EmptyPayload> { };
 178
 179        [System.Serializable]
 180        private class OnBlurEvent : UUIDEvent<EmptyPayload> { };
 181
 182        [System.Serializable]
 183        public class OnEnterEvent : UUIDEvent<OnEnterEventPayload> { };
 184
 185        [System.Serializable]
 186        public class OnClickEventPayload
 187        {
 188            public ACTION_BUTTON buttonId = ACTION_BUTTON.POINTER;
 189        }
 190
 191        [System.Serializable]
 192        public class SendChatMessageEvent
 193        {
 194            public ChatMessage message;
 195        }
 196
 197        [System.Serializable]
 198        public class RemoveEntityComponentsPayLoad
 199        {
 200            public string entityId;
 201            public string componentId;
 202        };
 203
 204        [System.Serializable]
 205        public class StoreSceneStateEvent
 206        {
 207            public string type = "StoreSceneState";
 208            public string payload = "";
 209        };
 210
 211        [System.Serializable]
 212        public class OnPointerEventPayload
 213        {
 214
 215            public ACTION_BUTTON buttonId;
 216            public Vector3 origin;
 217            public Vector3 direction;
 218            public Hit hit;
 219
 220            [System.Serializable]
 221            public class Hit
 222            {
 223                public Vector3 origin;
 224                public float length;
 225                public Vector3 hitPoint;
 226                public Vector3 normal;
 227                public Vector3 worldNormal;
 228                public string meshName;
 229                public string entityId;
 230            }
 231        }
 232
 233        [System.Serializable]
 234        public class OnGlobalPointerEventPayload : OnPointerEventPayload
 235        {
 236            public enum InputEventType
 237            {
 238                DOWN,
 239                UP
 240            }
 241
 242            public InputEventType type;
 243        }
 244
 245        [System.Serializable]
 246        public class OnTextSubmitEventPayload
 247        {
 248            public string id;
 249            public string text;
 250        }
 251
 252        [System.Serializable]
 253        public class OnTextInputChangeEventPayload
 254        {
 255            public string value;
 256        }
 257
 258        [System.Serializable]
 259        public class OnTextInputChangeTextEventPayload
 260        {
 261
 262            public Payload value = new Payload();
 263
 264            [System.Serializable]
 265            public class Payload
 266            {
 267                public string value;
 268                public bool isSubmit;
 269            }
 270        }
 271
 272        [System.Serializable]
 273        public class OnScrollChangeEventPayload
 274        {
 275            public Vector2 value;
 276            public int pointerId;
 277        }
 278
 279        [System.Serializable]
 280        public class EmptyPayload { }
 281
 282        [System.Serializable]
 283        public class MetricsModel
 284        {
 285            public int meshes;
 286            public int bodies;
 287            public int materials;
 288            public int textures;
 289            public int triangles;
 290            public int entities;
 291
 292            public static MetricsModel operator +(MetricsModel lhs, MetricsModel rhs)
 293            {
 294                return new MetricsModel()
 295                {
 296                    meshes = lhs.meshes + rhs.meshes,
 297                    bodies = lhs.bodies + rhs.bodies,
 298                    materials = lhs.materials + rhs.materials,
 299                    textures = lhs.textures + rhs.textures,
 300                    triangles = lhs.triangles + rhs.triangles,
 301                    entities = lhs.entities + rhs.entities
 302                };
 303            }
 304        }
 305
 306        [System.Serializable]
 307        private class OnMetricsUpdate
 308        {
 309            public MetricsModel given = new MetricsModel();
 310            public MetricsModel limit = new MetricsModel();
 311        }
 312
 313        [System.Serializable]
 314        public class OnEnterEventPayload { }
 315
 316        [System.Serializable]
 317        public class TransformPayload
 318        {
 319            public Vector3 position = Vector3.zero;
 320            public Quaternion rotation = Quaternion.identity;
 321            public Vector3 scale = Vector3.one;
 322        }
 323
 324        public class OnSendScreenshot
 325        {
 326            public string encodedTexture;
 327            public string id;
 328        };
 329
 330        [System.Serializable]
 331        public class GotoEvent
 332        {
 333            public int x;
 334            public int y;
 335        };
 336
 337        [System.Serializable]
 338        public class BaseResolution
 339        {
 340            public int baseResolution;
 341        };
 342
 343        //-----------------------------------------------------
 344        // Raycast
 345        [System.Serializable]
 346        public class RayInfo
 347        {
 348            public Vector3 origin;
 349            public Vector3 direction;
 350            public float distance;
 351        }
 352
 353        [System.Serializable]
 354        public class RaycastHitInfo
 355        {
 356            public bool didHit;
 357            public RayInfo ray;
 358
 359            public Vector3 hitPoint;
 360            public Vector3 hitNormal;
 361        }
 362
 363        [System.Serializable]
 364        public class HitEntityInfo
 365        {
 366            public string entityId;
 367            public string meshName;
 368        }
 369
 370        [System.Serializable]
 371        public class RaycastHitEntity : RaycastHitInfo
 372        {
 373            public HitEntityInfo entity;
 374        }
 375
 376        [System.Serializable]
 377        public class RaycastHitEntities : RaycastHitInfo
 378        {
 379            public RaycastHitEntity[] entities;
 380        }
 381
 382        [System.Serializable]
 383        public class RaycastResponse<T> where T : RaycastHitInfo
 384        {
 385            public string queryId;
 386            public string queryType;
 387            public T payload;
 388        }
 389
 390        // Note (Zak): We need to explicitly define this classes for the JsonUtility to
 391        // be able to serialize them
 392        [System.Serializable]
 393        public class RaycastHitFirstResponse : RaycastResponse<RaycastHitEntity> { }
 394
 395        [System.Serializable]
 396        public class RaycastHitAllResponse : RaycastResponse<RaycastHitEntities> { }
 397
 398        [System.Serializable]
 399        public class UserAcceptedCollectiblesPayload
 400        {
 401            public string id;
 402        }
 403
 404        [System.Serializable]
 405        public class SendBlockPlayerPayload
 406        {
 407            public string userId;
 408        }
 409
 410        [Serializable]
 411        private class SendReportPlayerPayload
 412        {
 413            public string userId;
 414            public string name;
 415        }
 416
 417        [Serializable]
 418        private class SendReportScenePayload
 419        {
 420            public int sceneNumber;
 421        }
 422
 423        [Serializable]
 424        private class SetHomeScenePayload
 425        {
 426            public string sceneCoords;
 427        }
 428
 429        [System.Serializable]
 430        public class SendUnblockPlayerPayload
 431        {
 432            public string userId;
 433        }
 434
 435        [System.Serializable]
 436        public class TutorialStepPayload
 437        {
 438            public int tutorialStep;
 439        }
 440
 441        [System.Serializable]
 442        public class PerformanceReportPayload
 443        {
 444            public string samples;
 445            public bool fpsIsCapped;
 446            public int hiccupsInThousandFrames;
 447            public float hiccupsTime;
 448            public float totalTime;
 449            public int gltfInProgress;
 450            public int gltfFailed;
 451            public int gltfCancelled;
 452            public int gltfLoaded;
 453            public int abInProgress;
 454            public int abFailed;
 455            public int abCancelled;
 456            public int abLoaded;
 457            public int gltfTexturesLoaded;
 458            public int abTexturesLoaded;
 459            public int promiseTexturesLoaded;
 460            public int enqueuedMessages;
 461            public int processedMessages;
 462            public int playerCount;
 463            public int loadRadius;
 464            public object drawCalls; //int *
 465            public object memoryReserved; //long, in total bytes *
 466            public object memoryUsage; //long, in total bytes *
 467            public object totalGCAlloc; //long, in total bytes, its the sum of all GCAllocs per frame over 1000 frames *
 468            public Dictionary<int, long> sceneScores;
 469
 470            //* is NULL if SendProfilerMetrics is false
 471        }
 472
 473        [System.Serializable]
 474        public class SystemInfoReportPayload
 475        {
 476            public string graphicsDeviceName = SystemInfo.graphicsDeviceName;
 477            public string graphicsDeviceVersion = SystemInfo.graphicsDeviceVersion;
 478            public int graphicsMemorySize = SystemInfo.graphicsMemorySize;
 479            public string processorType = SystemInfo.processorType;
 480            public int processorCount = SystemInfo.processorCount;
 481            public int systemMemorySize = SystemInfo.systemMemorySize;
 482
 483            // TODO: remove useBinaryTransform after ECS7 is fully in prod
 484            public bool useBinaryTransform = true;
 485        }
 486
 487        [System.Serializable]
 488        public class GenericAnalyticPayload
 489        {
 490            public string eventName;
 491            public Dictionary<object, object> data;
 492        }
 493
 494        [System.Serializable]
 495        public class PerformanceHiccupPayload
 496        {
 497            public int hiccupsInThousandFrames;
 498            public float hiccupsTime;
 499            public float totalTime;
 500        }
 501
 502        [System.Serializable]
 503        public class TermsOfServiceResponsePayload
 504        {
 505            public int sceneNumber;
 506            public bool dontShowAgain;
 507            public bool accepted;
 508        }
 509
 510        [System.Serializable]
 511        public class OpenURLPayload
 512        {
 513            public string url;
 514        }
 515
 516        [System.Serializable]
 517        public class GIFSetupPayload
 518        {
 519            public string imageSource;
 520            public string id;
 521            public bool isWebGL1;
 522        }
 523
 524        [System.Serializable]
 525        public class RequestScenesInfoAroundParcelPayload
 526        {
 527            public Vector2 parcel;
 528            public int scenesAround;
 529        }
 530
 531        [System.Serializable]
 532        public class AudioStreamingPayload
 533        {
 534            public string url;
 535            public bool play;
 536            public float volume;
 537        }
 538
 539        [System.Serializable]
 540        public class SetScenesLoadRadiusPayload
 541        {
 542            public float newRadius;
 543        }
 544
 545        [System.Serializable]
 546        public class SetVoiceChatRecordingPayload
 547        {
 548            public bool recording;
 549        }
 550
 551        [System.Serializable]
 552        public class ApplySettingsPayload
 553        {
 554            public float voiceChatVolume;
 555            public int voiceChatAllowCategory;
 556        }
 557
 558        [Serializable]
 559        public class UserRealmPayload
 560        {
 561            public string serverName;
 562            public string layer;
 563        }
 564
 565        [System.Serializable]
 566        public class JumpInPayload
 567        {
 568            public UserRealmPayload realm = new UserRealmPayload();
 569            public Vector2 gridPosition;
 570        }
 571
 572        [System.Serializable]
 573        public class LoadingFeedbackMessage
 574        {
 575            public string message;
 576            public int loadPercentage;
 577        }
 578
 579        [System.Serializable]
 580        public class AnalyticsPayload
 581        {
 582
 583            public string name;
 584            public Property[] properties;
 585
 586            [System.Serializable]
 587            public class Property
 588            {
 589                public string key;
 590                public string value;
 591
 592                public Property(string key, string value)
 593                {
 594                    this.key = key;
 595                    this.value = value;
 596                }
 597            }
 598        }
 599
 600        [System.Serializable]
 601        public class DelightedSurveyEnabledPayload
 602        {
 603            public bool enabled;
 604        }
 605
 606        [System.Serializable]
 607        public class ExternalActionSceneEventPayload
 608        {
 609            public string type;
 610            public string payload;
 611        }
 612
 613        [System.Serializable]
 614        public class MuteUserPayload
 615        {
 616            public string[] usersId;
 617            public bool mute;
 618        }
 619
 620        [System.Serializable]
 621        public class CloseUserAvatarPayload
 622        {
 623            public bool isSignUpFlow;
 624        }
 625
 626        [System.Serializable]
 627        public class StringPayload
 628        {
 629            public string value;
 630        }
 631
 632        [System.Serializable]
 633        public class KillPortableExperiencePayload
 634        {
 635            public string portableExperienceId;
 636        }
 637
 638        [System.Serializable]
 639        public class SetDisabledPortableExperiencesPayload
 640        {
 641            public string[] idsToDisable;
 642        }
 643
 644        [System.Serializable]
 645        public class WearablesRequestFiltersPayload
 646        {
 647            public string ownedByUser;
 648            public string[] wearableIds;
 649            public string[] collectionIds;
 650            public string thirdPartyId;
 651        }
 652
 653        [System.Serializable]
 654        public class EmotesRequestFiltersPayload
 655        {
 656            public string ownedByUser;
 657            public string[] emoteIds;
 658            public string[] collectionIds;
 659            public string thirdPartyId;
 660        }
 661
 662        [System.Serializable]
 663        public class RequestWearablesPayload
 664        {
 665            public WearablesRequestFiltersPayload filters;
 666            public string context;
 667        }
 668
 669        [System.Serializable]
 670        public class RequestEmotesPayload
 671        {
 672            public EmotesRequestFiltersPayload filters;
 673            public string context;
 674        }
 675
 676        [System.Serializable]
 677        public class HeadersPayload
 678        {
 679            public string method;
 680            public string url;
 681            public Dictionary<string, object> metadata = new Dictionary<string, object>();
 682        }
 683
 684        [System.Serializable]
 685        public class SearchENSOwnerPayload
 686        {
 687            public string name;
 688            public int maxResults;
 689        }
 690
 691        [System.Serializable]
 692        public class UnpublishScenePayload
 693        {
 694            public string coordinates;
 695        }
 696
 697        [System.Serializable]
 698        public class AvatarStateBase
 699        {
 700            public string type;
 701            public string avatarShapeId;
 702        }
 703
 704        [System.Serializable]
 705        public class AvatarStateSceneChanged : AvatarStateBase
 706        {
 707            public int sceneNumber;
 708        }
 709
 710        [System.Serializable]
 711        public class AvatarOnClickPayload
 712        {
 713            public string userId;
 714            public RayInfo ray = new RayInfo();
 715        }
 716
 717        [System.Serializable]
 718        public class TimeReportPayload
 719        {
 720            public float timeNormalizationFactor;
 721            public float cycleTime;
 722            public bool isPaused;
 723            public float time;
 724        }
 725
 726        [System.Serializable]
 727        public class GetFriendsWithDirectMessagesPayload
 728        {
 729            public string userNameOrId;
 730            public int limit;
 731            public int skip;
 732        }
 733
 734        [System.Serializable]
 735        public class MarkMessagesAsSeenPayload
 736        {
 737            public string userId;
 738        }
 739
 740        [System.Serializable]
 741        public class MarkChannelMessagesAsSeenPayload
 742        {
 743            public string channelId;
 744        }
 745
 746        [System.Serializable]
 747        public class GetPrivateMessagesPayload
 748        {
 749            public string userId;
 750            public int limit;
 751            public string fromMessageId;
 752        }
 753
 754        [Serializable]
 755        public class FriendshipUpdateStatusMessage
 756        {
 757            public string userId;
 758            public FriendshipAction action;
 759        }
 760
 761        [Serializable]
 762        public class SetInputAudioDevicePayload
 763        {
 764            public string deviceId;
 765        }
 766
 767        public enum FriendshipAction
 768        {
 769            NONE,
 770            APPROVED,
 771            REJECTED,
 772            CANCELLED,
 773            REQUESTED_FROM,
 774            REQUESTED_TO,
 775            DELETED
 776        }
 777
 778        [Serializable]
 779        private class GetFriendsPayload
 780        {
 781            public string userNameOrId;
 782            public int limit;
 783            public int skip;
 784        }
 785
 786        [Serializable]
 787        private class LeaveChannelPayload
 788        {
 789            public string channelId;
 790        }
 791
 792        [Serializable]
 793        private class CreateChannelPayload
 794        {
 795            public string channelId;
 796        }
 797
 798        public struct MuteChannelPayload
 799        {
 800            public string channelId;
 801            public bool muted;
 802        }
 803
 804        [Serializable]
 805        private class JoinOrCreateChannelPayload
 806        {
 807            public string channelId;
 808        }
 809
 810        [Serializable]
 811        private class GetChannelMessagesPayload
 812        {
 813            public string channelId;
 814            public int limit;
 815            public string from;
 816        }
 817
 818        [Serializable]
 819        private class GetJoinedChannelsPayload
 820        {
 821            public int limit;
 822            public int skip;
 823        }
 824
 825        [Serializable]
 826        private class GetChannelsPayload
 827        {
 828            public int limit;
 829            public string since;
 830            public string name;
 831        }
 832
 833        [Serializable]
 834        private class GetChannelInfoPayload
 835        {
 836            public string[] channelIds;
 837        }
 838
 839        [Serializable]
 840        private class GetChannelMembersPayload
 841        {
 842            public string channelId;
 843            public int limit;
 844            public int skip;
 845            public string userName;
 846        }
 847
 848        public static event Action<string, byte[]> OnBinaryMessageFromEngine;
 849
 850#if UNITY_WEBGL && !UNITY_EDITOR
 851    /**
 852     * This method is called after the first render. It marks the loading of the
 853     * rest of the JS client.
 854     */
 855    [DllImport("__Internal")] public static extern void StartDecentraland();
 856    [DllImport("__Internal")] public static extern void MessageFromEngine(string type, string message);
 857    [DllImport("__Internal")] public static extern string GetGraphicCard();
 858
 859    public static System.Action<string, string> OnMessageFromEngine;
 860#else
 861        public static Action<string, string> OnMessageFromEngine
 862        {
 863            set
 864            {
 865                OnMessage = value;
 866                if (OnMessage != null)
 867                {
 868                    ProcessQueuedMessages();
 869                }
 870            }
 871            get => OnMessage;
 872        }
 873        private static Action<string, string> OnMessage;
 874
 875        private static bool hasQueuedMessages = false;
 876        private static List<(string, string)> queuedMessages = new List<(string, string)>();
 877        public static void StartDecentraland() { }
 878        public static bool CheckURLParam(string targetParam) { return false; }
 879        public static string GetURLParam(string targetParam) { return String.Empty; }
 880
 881        public static void MessageFromEngine(string type, string message)
 882        {
 883            if (OnMessageFromEngine != null)
 884            {
 885                if (hasQueuedMessages)
 886                {
 887                    ProcessQueuedMessages();
 888                }
 889
 890                OnMessageFromEngine.Invoke(type, message);
 891                if (VERBOSE)
 892                {
 893                    Debug.Log("MessageFromEngine called with: " + type + ", " + message);
 894                }
 895            }
 896            else
 897            {
 898                lock (queuedMessages)
 899                {
 900                    queuedMessages.Add((type, message));
 901                }
 902
 903                hasQueuedMessages = true;
 904            }
 905        }
 906
 907        private static void ProcessQueuedMessages()
 908        {
 909            hasQueuedMessages = false;
 910            lock (queuedMessages)
 911            {
 912                foreach ((string type, string payload) in queuedMessages)
 913                {
 914                    MessageFromEngine(type, payload);
 915                }
 916
 917                queuedMessages.Clear();
 918            }
 919        }
 920
 921        public static string GetGraphicCard() => "In Editor Graphic Card";
 922#endif
 923
 924        public static void SendMessage(string type)
 925        {
 926            // sending an empty JSON object to be compatible with other messages
 927            MessageFromEngine(type, "{}");
 928        }
 929
 930        public static void SendMessage<T>(string type, T message)
 931        {
 932            string messageJson = JsonUtility.ToJson(message);
 933            SendJson(type, messageJson);
 934        }
 935
 936        public static void SendJson(string type, string json)
 937        {
 938            if (VERBOSE)
 939            {
 940                Debug.Log($"Sending message: " + json);
 941            }
 942
 943            MessageFromEngine(type, json);
 944        }
 945
 946        private static ReportPositionPayload positionPayload = new ReportPositionPayload();
 947        private static CameraModePayload cameraModePayload = new CameraModePayload();
 948        private static Web3UseResponsePayload web3UseResponsePayload = new Web3UseResponsePayload();
 949        private static IdleStateChangedPayload idleStateChangedPayload = new IdleStateChangedPayload();
 950        private static OnMetricsUpdate onMetricsUpdate = new OnMetricsUpdate();
 951        private static OnClickEvent onClickEvent = new OnClickEvent();
 952        private static OnPointerDownEvent onPointerDownEvent = new OnPointerDownEvent();
 953        private static OnPointerUpEvent onPointerUpEvent = new OnPointerUpEvent();
 954        private static OnTextSubmitEvent onTextSubmitEvent = new OnTextSubmitEvent();
 955        private static OnTextInputChangeEvent onTextInputChangeEvent = new OnTextInputChangeEvent();
 956        private static OnTextInputChangeTextEvent onTextInputChangeTextEvent = new OnTextInputChangeTextEvent();
 957        private static OnScrollChangeEvent onScrollChangeEvent = new OnScrollChangeEvent();
 958        private static OnFocusEvent onFocusEvent = new OnFocusEvent();
 959        private static OnBlurEvent onBlurEvent = new OnBlurEvent();
 960        private static OnEnterEvent onEnterEvent = new OnEnterEvent();
 961        private static OnSendScreenshot onSendScreenshot = new OnSendScreenshot();
 962        private static OnPointerEventPayload onPointerEventPayload = new OnPointerEventPayload();
 963        private static OnGlobalPointerEventPayload onGlobalPointerEventPayload = new OnGlobalPointerEventPayload();
 964        private static OnGlobalPointerEvent onGlobalPointerEvent = new OnGlobalPointerEvent();
 965        private static AudioStreamingPayload onAudioStreamingEvent = new AudioStreamingPayload();
 966        private static SetVoiceChatRecordingPayload setVoiceChatRecordingPayload = new SetVoiceChatRecordingPayload();
 967        private static SetScenesLoadRadiusPayload setScenesLoadRadiusPayload = new SetScenesLoadRadiusPayload();
 968        private static ApplySettingsPayload applySettingsPayload = new ApplySettingsPayload();
 969        private static GIFSetupPayload gifSetupPayload = new GIFSetupPayload();
 970        private static JumpInPayload jumpInPayload = new JumpInPayload();
 971        private static GotoEvent gotoEvent = new GotoEvent();
 972        private static SendChatMessageEvent sendChatMessageEvent = new SendChatMessageEvent();
 973        private static BaseResolution baseResEvent = new BaseResolution();
 974        private static AnalyticsPayload analyticsEvent = new AnalyticsPayload();
 975        private static DelightedSurveyEnabledPayload delightedSurveyEnabled = new DelightedSurveyEnabledPayload();
 976        private static ExternalActionSceneEventPayload sceneExternalActionEvent = new ExternalActionSceneEventPayload();
 977        private static MuteUserPayload muteUserEvent = new MuteUserPayload();
 978        private static StoreSceneStateEvent storeSceneState = new StoreSceneStateEvent();
 979        private static CloseUserAvatarPayload closeUserAvatarPayload = new CloseUserAvatarPayload();
 980        private static StringPayload stringPayload = new StringPayload();
 981        private static KillPortableExperiencePayload killPortableExperiencePayload = new KillPortableExperiencePayload()
 982        private static SetDisabledPortableExperiencesPayload setDisabledPortableExperiencesPayload = new SetDisabledPort
 983        private static RequestWearablesPayload requestWearablesPayload = new RequestWearablesPayload();
 984        private static RequestEmotesPayload requestEmotesPayload = new RequestEmotesPayload();
 985        private static SearchENSOwnerPayload searchEnsOwnerPayload = new SearchENSOwnerPayload();
 986        private static HeadersPayload headersPayload = new HeadersPayload();
 987        private static AvatarStateBase avatarStatePayload = new AvatarStateBase();
 988        private static AvatarStateSceneChanged avatarSceneChangedPayload = new AvatarStateSceneChanged();
 989        public static AvatarOnClickPayload avatarOnClickPayload = new AvatarOnClickPayload();
 990        private static UUIDEvent<EmptyPayload> onPointerHoverEnterEvent = new UUIDEvent<EmptyPayload>();
 991        private static UUIDEvent<EmptyPayload> onPointerHoverExitEvent = new UUIDEvent<EmptyPayload>();
 992        private static TimeReportPayload timeReportPayload = new TimeReportPayload();
 993        private static GetFriendsWithDirectMessagesPayload getFriendsWithDirectMessagesPayload = new GetFriendsWithDirec
 994        private static MarkMessagesAsSeenPayload markMessagesAsSeenPayload = new MarkMessagesAsSeenPayload();
 995        private static MarkChannelMessagesAsSeenPayload markChannelMessagesAsSeenPayload = new MarkChannelMessagesAsSeen
 996        private static GetPrivateMessagesPayload getPrivateMessagesPayload = new GetPrivateMessagesPayload();
 997
 998        public static void SendSceneEvent<T> (int sceneNumber, string eventType, T payload)
 999        {
 1000            SceneEvent<T> sceneEvent = new SceneEvent<T>();
 1001            sceneEvent.sceneNumber = sceneNumber;
 1002            sceneEvent.eventType = eventType;
 1003            sceneEvent.payload = payload;
 1004
 1005            SendMessage("SceneEvent", sceneEvent);
 1006        }
 1007
 1008        private static void SendAllScenesEvent<T>(string eventType, T payload)
 1009        {
 1010            AllScenesEvent<T> allScenesEvent = new AllScenesEvent<T>();
 1011            allScenesEvent.eventType = eventType;
 1012            allScenesEvent.payload = payload;
 1013
 1014            SendMessage("AllScenesEvent", allScenesEvent);
 1015        }
 1016
 1017        public static void ReportPosition(Vector3 position, Quaternion rotation, float playerHeight, Quaternion cameraRo
 1018        {
 1019            positionPayload.position = position;
 1020            positionPayload.rotation = rotation;
 1021            positionPayload.playerHeight = playerHeight;
 1022            positionPayload.cameraRotation = cameraRotation;
 1023
 1024            SendMessage("ReportPosition", positionPayload);
 1025        }
 1026
 1027        public static void ReportCameraChanged(CameraMode.ModeId cameraMode) { ReportCameraChanged(cameraMode, -1); }
 1028
 1029        public static void ReportCameraChanged(CameraMode.ModeId cameraMode, int targetSceneNumber)
 1030        {
 1031            cameraModePayload.cameraMode = cameraMode;
 1032            if (targetSceneNumber > 0)
 1033            {
 1034                SendSceneEvent(targetSceneNumber, "cameraModeChanged", cameraModePayload);
 1035            }
 1036            else
 1037            {
 1038                SendAllScenesEvent("cameraModeChanged", cameraModePayload);
 1039            }
 1040        }
 1041
 1042        public static void Web3UseResponse(string id, bool result)
 1043        {
 1044            web3UseResponsePayload.id = id;
 1045            web3UseResponsePayload.result = result;
 1046            SendMessage("Web3UseResponse", web3UseResponsePayload);
 1047        }
 1048
 1049        public static void ReportIdleStateChanged(bool isIdle)
 1050        {
 1051            idleStateChangedPayload.isIdle = isIdle;
 1052            SendAllScenesEvent("idleStateChanged", idleStateChangedPayload);
 1053        }
 1054
 1055        public static void ReportControlEvent<T>(T controlEvent) where T : ControlEvent { SendMessage("ControlEvent", co
 1056
 1057        public static void SendRequestHeadersForUrl(string eventName, string method, string url, Dictionary<string, obje
 1058        {
 1059            headersPayload.method = method;
 1060            headersPayload.url = url;
 1061            if (metadata != null)
 1062                headersPayload.metadata = metadata;
 1063            SendMessage(eventName, headersPayload);
 1064        }
 1065
 1066        public static void BuilderInWorldMessage(string type, string message) { MessageFromEngine(type, message); }
 1067
 1068        public static void ReportOnClickEvent(int sceneNumber, string uuid)
 1069        {
 1070            if (string.IsNullOrEmpty(uuid))
 1071            {
 1072                return;
 1073            }
 1074
 1075            onClickEvent.uuid = uuid;
 1076
 1077            SendSceneEvent(sceneNumber, "uuidEvent", onClickEvent);
 1078        }
 1079
 1080        // TODO: Add sceneNumber to this response
 1081        private static void ReportRaycastResult<T, P>(int sceneNumber, string queryId, string queryType, P payload) wher
 1082        {
 1083            T response = new T();
 1084            response.queryId = queryId;
 1085            response.queryType = queryType;
 1086            response.payload = payload;
 1087
 1088            SendSceneEvent<T>(sceneNumber, "raycastResponse", response);
 1089        }
 1090
 1091        public static void ReportRaycastHitFirstResult(int sceneNumber, string queryId, RaycastType raycastType, Raycast
 1092
 1093        public static void ReportRaycastHitAllResult(int sceneNumber, string queryId, RaycastType raycastType, RaycastHi
 1094
 1095        private static OnPointerEventPayload.Hit CreateHitObject(string entityId, string meshName, Vector3 point,
 1096            Vector3 normal, float distance)
 1097        {
 1098            OnPointerEventPayload.Hit hit = new OnPointerEventPayload.Hit();
 1099
 1100            hit.hitPoint = point;
 1101            hit.length = distance;
 1102            hit.normal = normal;
 1103            hit.worldNormal = normal;
 1104            hit.meshName = meshName;
 1105            hit.entityId = entityId;
 1106
 1107            return hit;
 1108        }
 1109
 1110        private static void SetPointerEventPayload(OnPointerEventPayload pointerEventPayload, ACTION_BUTTON buttonId,
 1111            string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance,
 1112            bool isHitInfoValid)
 1113        {
 1114            pointerEventPayload.origin = ray.origin;
 1115            pointerEventPayload.direction = ray.direction;
 1116            pointerEventPayload.buttonId = buttonId;
 1117
 1118            if (isHitInfoValid)
 1119                pointerEventPayload.hit = CreateHitObject(entityId, meshName, point, normal, distance);
 1120            else
 1121                pointerEventPayload.hit = null;
 1122        }
 1123
 1124        public static void ReportGlobalPointerDownEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal,
 1125            float distance, int sceneNumber, string entityId = "0", string meshName = null, bool isHitInfoValid = false)
 1126        {
 1127            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId,
 1128                entityId, meshName, ray, point, normal, distance,
 1129                isHitInfoValid);
 1130            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.DOWN;
 1131
 1132            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 1133
 1134            SendSceneEvent(sceneNumber, "actionButtonEvent", onGlobalPointerEvent);
 1135        }
 1136
 1137        public static void ReportGlobalPointerUpEvent(ACTION_BUTTON buttonId, Ray ray, Vector3 point, Vector3 normal,
 1138            float distance, int sceneNumber, string entityId = "0", string meshName = null, bool isHitInfoValid = false)
 1139        {
 1140            SetPointerEventPayload((OnPointerEventPayload) onGlobalPointerEventPayload, buttonId,
 1141                entityId, meshName, ray, point, normal, distance,
 1142                isHitInfoValid);
 1143            onGlobalPointerEventPayload.type = OnGlobalPointerEventPayload.InputEventType.UP;
 1144
 1145            onGlobalPointerEvent.payload = onGlobalPointerEventPayload;
 1146
 1147            SendSceneEvent(sceneNumber, "actionButtonEvent", onGlobalPointerEvent);
 1148        }
 1149
 1150        public static void ReportOnPointerDownEvent(ACTION_BUTTON buttonId, int sceneNumber, string uuid,
 1151            string entityId, string meshName, Ray ray, Vector3 point, Vector3 normal, float distance)
 1152        {
 1153            if (string.IsNullOrEmpty(uuid))
 1154            {
 1155                return;
 1156            }
 1157
 1158            onPointerDownEvent.uuid = uuid;
 1159            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point,
 1160                normal, distance, isHitInfoValid: true);
 1161            onPointerDownEvent.payload = onPointerEventPayload;
 1162
 1163            SendSceneEvent(sceneNumber, "uuidEvent", onPointerDownEvent);
 1164        }
 1165
 1166        public static void ReportOnPointerUpEvent(ACTION_BUTTON buttonId, int sceneNumber, string uuid, string entityId,
 1167            string meshName, Ray ray, Vector3 point, Vector3 normal, float distance)
 1168        {
 1169            if (string.IsNullOrEmpty(uuid))
 1170            {
 1171                return;
 1172            }
 1173
 1174            onPointerUpEvent.uuid = uuid;
 1175            SetPointerEventPayload(onPointerEventPayload, buttonId, entityId, meshName, ray, point,
 1176                normal, distance, isHitInfoValid: true);
 1177            onPointerUpEvent.payload = onPointerEventPayload;
 1178
 1179            SendSceneEvent(sceneNumber, "uuidEvent", onPointerUpEvent);
 1180        }
 1181
 1182        public static void ReportOnTextSubmitEvent(int sceneNumber, string uuid, string text)
 1183        {
 1184            if (string.IsNullOrEmpty(uuid))
 1185            {
 1186                return;
 1187            }
 1188
 1189            onTextSubmitEvent.uuid = uuid;
 1190            onTextSubmitEvent.payload.text = text;
 1191
 1192            SendSceneEvent(sceneNumber, "uuidEvent", onTextSubmitEvent);
 1193        }
 1194
 1195        public static void ReportOnTextInputChangedEvent(int sceneNumber, string uuid, string text)
 1196        {
 1197            if (string.IsNullOrEmpty(uuid))
 1198            {
 1199                return;
 1200            }
 1201
 1202            onTextInputChangeEvent.uuid = uuid;
 1203            onTextInputChangeEvent.payload.value = text;
 1204
 1205            SendSceneEvent(sceneNumber, "uuidEvent", onTextInputChangeEvent);
 1206        }
 1207
 1208        public static void ReportOnTextInputChangedTextEvent(int sceneNumber, string uuid, string text, bool isSubmit)
 1209        {
 1210            if (string.IsNullOrEmpty(uuid))
 1211            {
 1212                return;
 1213            }
 1214
 1215            onTextInputChangeTextEvent.uuid = uuid;
 1216            onTextInputChangeTextEvent.payload.value.value = text;
 1217            onTextInputChangeTextEvent.payload.value.isSubmit = isSubmit;
 1218
 1219            SendSceneEvent(sceneNumber, "uuidEvent", onTextInputChangeTextEvent);
 1220        }
 1221
 1222        public static void ReportOnFocusEvent(int sceneNumber, string uuid)
 1223        {
 1224            if (string.IsNullOrEmpty(uuid))
 1225            {
 1226                return;
 1227            }
 1228
 1229            onFocusEvent.uuid = uuid;
 1230            SendSceneEvent(sceneNumber, "uuidEvent", onFocusEvent);
 1231        }
 1232
 1233        public static void ReportOnBlurEvent(int sceneNumber, string uuid)
 1234        {
 1235            if (string.IsNullOrEmpty(uuid))
 1236            {
 1237                return;
 1238            }
 1239
 1240            onBlurEvent.uuid = uuid;
 1241            SendSceneEvent(sceneNumber, "uuidEvent", onBlurEvent);
 1242        }
 1243
 1244        public static void ReportOnScrollChange(int sceneNumber, string uuid, Vector2 value, int pointerId)
 1245        {
 1246            if (string.IsNullOrEmpty(uuid))
 1247            {
 1248                return;
 1249            }
 1250
 1251            onScrollChangeEvent.uuid = uuid;
 1252            onScrollChangeEvent.payload.value = value;
 1253            onScrollChangeEvent.payload.pointerId = pointerId;
 1254
 1255            SendSceneEvent(sceneNumber, "uuidEvent", onScrollChangeEvent);
 1256        }
 1257
 1258        public static void ReportEvent<T>(int sceneNumber, T @event) { SendSceneEvent(sceneNumber, "uuidEvent", @event);
 1259
 1260        public static void ReportOnMetricsUpdate(int sceneNumber, MetricsModel current,
 1261            MetricsModel limit)
 1262        {
 1263            onMetricsUpdate.given = current;
 1264            onMetricsUpdate.limit = limit;
 1265
 1266            SendSceneEvent(sceneNumber, "metricsUpdate", onMetricsUpdate);
 1267        }
 1268
 1269        public static void ReportOnEnterEvent(int sceneNumber, string uuid)
 1270        {
 1271            if (string.IsNullOrEmpty(uuid))
 1272                return;
 1273
 1274            onEnterEvent.uuid = uuid;
 1275
 1276            SendSceneEvent(sceneNumber, "uuidEvent", onEnterEvent);
 1277        }
 1278
 1279        public static void LogOut() { SendMessage("LogOut"); }
 1280
 1281        public static void RedirectToSignUp() { SendMessage("RedirectToSignUp"); }
 1282
 1283        public static void PreloadFinished(int sceneNumber) { SendMessage("PreloadFinished", sceneNumber); }
 1284
 1285        public static void ReportMousePosition(Vector3 mousePosition, string id)
 1286        {
 1287            positionPayload.mousePosition = mousePosition;
 1288            positionPayload.id = id;
 1289            SendMessage("ReportMousePosition", positionPayload);
 1290        }
 1291
 1292        public static void SendScreenshot(string encodedTexture, string id)
 1293        {
 1294            onSendScreenshot.encodedTexture = encodedTexture;
 1295            onSendScreenshot.id = id;
 1296            SendMessage("SendScreenshot", onSendScreenshot);
 1297        }
 1298
 1299        public static void SetDelightedSurveyEnabled(bool enabled)
 1300        {
 1301            delightedSurveyEnabled.enabled = enabled;
 1302            SendMessage("SetDelightedSurveyEnabled", delightedSurveyEnabled);
 1303        }
 1304
 1305        public static void SetScenesLoadRadius(float newRadius)
 1306        {
 1307            setScenesLoadRadiusPayload.newRadius = newRadius;
 1308            SendMessage("SetScenesLoadRadius", setScenesLoadRadiusPayload);
 1309        }
 1310
 1311        [System.Serializable]
 1312        public class SaveAvatarPayload
 1313        {
 1314            public string face256;
 1315            public string body;
 1316            public bool isSignUpFlow;
 1317            public AvatarModel avatar;
 1318        }
 1319
 1320        public static class RendererAuthenticationType
 1321        {
 1322            public static string Guest => "guest";
 1323            public static string WalletConnect => "wallet_connect";
 1324        }
 1325
 1326        [System.Serializable]
 1327        public class SendAuthenticationPayload
 1328        {
 1329            public string rendererAuthenticationType;
 1330        }
 1331
 1332        [System.Serializable]
 1333        public class SendPassportPayload
 1334        {
 1335            public string name;
 1336            public string email;
 1337        }
 1338
 1339        [System.Serializable]
 1340        public class SendSaveUserUnverifiedNamePayload
 1341        {
 1342            public string newUnverifiedName;
 1343        }
 1344
 1345        [System.Serializable]
 1346        public class SendSaveUserDescriptionPayload
 1347        {
 1348            public string description;
 1349
 1350            public SendSaveUserDescriptionPayload(string description) { this.description = description; }
 1351        }
 1352
 1353        [System.Serializable]
 1354        public class SendRequestUserProfilePayload
 1355        {
 1356            public string value;
 1357        }
 1358
 1359        [Serializable]
 1360        public class SendVideoProgressEvent
 1361        {
 1362            public string componentId;
 1363            public int sceneNumber;
 1364            public string videoTextureId;
 1365            public int status;
 1366            public float currentOffset;
 1367            public float videoLength;
 1368        }
 1369
 1370        public static void RequestOwnProfileUpdate() { SendMessage("RequestOwnProfileUpdate"); }
 1371
 1372        public static void SendSaveAvatar(AvatarModel avatar, Texture2D face256Snapshot, Texture2D bodySnapshot, bool is
 1373        {
 1374            var payload = new SaveAvatarPayload()
 1375            {
 1376                avatar = avatar,
 1377                face256 = System.Convert.ToBase64String(face256Snapshot.EncodeToPNG()),
 1378                body = System.Convert.ToBase64String(bodySnapshot.EncodeToPNG()),
 1379                isSignUpFlow = isSignUpFlow
 1380            };
 1381            SendMessage("SaveUserAvatar", payload);
 1382        }
 1383
 1384        public static void SendAuthentication(string rendererAuthenticationType) { SendMessage("SendAuthentication", new
 1385
 1386        public static void SendPassport(string name, string email) { SendMessage("SendPassport", new SendPassportPayload
 1387
 1388        public static void SendSaveUserUnverifiedName(string newName)
 1389        {
 1390            var payload = new SendSaveUserUnverifiedNamePayload()
 1391            {
 1392                newUnverifiedName = newName
 1393            };
 1394
 1395            SendMessage("SaveUserUnverifiedName", payload);
 1396        }
 1397
 1398        public static void SendSaveUserDescription(string about) { SendMessage("SaveUserDescription", new SendSaveUserDe
 1399
 1400        public static void SendRequestUserProfile(string userId) { SendMessage("RequestUserProfile", new SendRequestUser
 1401
 1402        public static void SendUserAcceptedCollectibles(string airdropId) { SendMessage("UserAcceptedCollectibles", new 
 1403
 1404        public static void SaveUserTutorialStep(int newTutorialStep) { SendMessage("SaveUserTutorialStep", new TutorialS
 1405
 1406        public static void SendPerformanceReport(string performanceReportPayload) { SendJson("PerformanceReport", perfor
 1407
 1408        public static void SendSystemInfoReport() { SendMessage("SystemInfoReport", new SystemInfoReportPayload()); }
 1409
 1410        public static void SendTermsOfServiceResponse(int sceneNumber, bool accepted, bool dontShowAgain)
 1411        {
 1412            var payload = new TermsOfServiceResponsePayload()
 1413            {
 1414                sceneNumber = sceneNumber,
 1415                accepted = accepted,
 1416                dontShowAgain = dontShowAgain
 1417            };
 1418            SendMessage("TermsOfServiceResponse", payload);
 1419        }
 1420
 1421        public static void OpenURL(string url)
 1422        {
 1423#if UNITY_WEBGL
 1424            SendMessage("OpenWebURL", new OpenURLPayload { url = url });
 1425#else
 1426            Application.OpenURL(url);
 1427#endif
 1428        }
 1429
 1430        public static void PublishStatefulScene(ProtocolV2.PublishPayload payload) { MessageFromEngine("PublishSceneStat
 1431
 1432        public static void SendReportScene(int sceneNumber)
 1433        {
 1434            SendMessage("ReportScene", new SendReportScenePayload
 1435            {
 1436                sceneNumber = sceneNumber
 1437            });
 1438        }
 1439
 1440        public static void SetHomeScene(string sceneCoords)
 1441        {
 1442            SendMessage("SetHomeScene", new SetHomeScenePayload
 1443            {
 1444                sceneCoords = sceneCoords
 1445            });
 1446        }
 1447
 1448        public static void SendReportPlayer(string playerId, string playerName)
 1449        {
 1450            SendMessage("ReportPlayer", new SendReportPlayerPayload
 1451            {
 1452                userId = playerId,
 1453                name = playerName
 1454            });
 1455        }
 1456
 1457        public static void SendBlockPlayer(string userId)
 1458        {
 1459            SendMessage("BlockPlayer", new SendBlockPlayerPayload()
 1460            {
 1461                userId = userId
 1462            });
 1463        }
 1464
 1465        public static void SendUnblockPlayer(string userId)
 1466        {
 1467            SendMessage("UnblockPlayer", new SendUnblockPlayerPayload()
 1468            {
 1469                userId = userId
 1470            });
 1471        }
 1472
 1473        public static void RequestScenesInfoAroundParcel(Vector2 parcel, int maxScenesArea)
 1474        {
 1475            SendMessage("RequestScenesInfoInArea", new RequestScenesInfoAroundParcelPayload()
 1476            {
 1477                parcel = parcel,
 1478                scenesAround = maxScenesArea
 1479            });
 1480        }
 1481
 1482        public static void SendAudioStreamEvent(string url, bool play, float volume)
 1483        {
 1484            onAudioStreamingEvent.url = url;
 1485            onAudioStreamingEvent.play = play;
 1486            onAudioStreamingEvent.volume = volume;
 1487            SendMessage("SetAudioStream", onAudioStreamingEvent);
 1488        }
 1489
 1490        public static void JoinVoiceChat() { SendMessage("JoinVoiceChat"); }
 1491
 1492        public static void LeaveVoiceChat() { SendMessage("LeaveVoiceChat"); }
 1493
 1494        public static void SendSetVoiceChatRecording(bool recording)
 1495        {
 1496            setVoiceChatRecordingPayload.recording = recording;
 1497            SendMessage("SetVoiceChatRecording", setVoiceChatRecordingPayload);
 1498        }
 1499
 1500        public static void ToggleVoiceChatRecording() { SendMessage("ToggleVoiceChatRecording"); }
 1501
 1502        public static void ApplySettings(float voiceChatVolume, int voiceChatAllowCategory)
 1503        {
 1504            applySettingsPayload.voiceChatVolume = voiceChatVolume;
 1505            applySettingsPayload.voiceChatAllowCategory = voiceChatAllowCategory;
 1506            SendMessage("ApplySettings", applySettingsPayload);
 1507        }
 1508
 1509        public static void RequestGIFProcessor(string gifURL, string gifId, bool isWebGL1)
 1510        {
 1511            gifSetupPayload.imageSource = gifURL;
 1512            gifSetupPayload.id = gifId;
 1513            gifSetupPayload.isWebGL1 = isWebGL1;
 1514
 1515            SendMessage("RequestGIFProcessor", gifSetupPayload);
 1516        }
 1517
 1518        public static void DeleteGIF(string id)
 1519        {
 1520            stringPayload.value = id;
 1521            SendMessage("DeleteGIF", stringPayload);
 1522        }
 1523
 1524        public static void GoTo(int x, int y)
 1525        {
 1526            gotoEvent.x = x;
 1527            gotoEvent.y = y;
 1528            SendMessage("GoTo", gotoEvent);
 1529        }
 1530
 1531        public static void GoToCrowd()
 1532        {
 1533            SendMessage("GoToCrowd");
 1534        }
 1535
 1536        public static void GoToMagic()
 1537        {
 1538            SendMessage("GoToMagic");
 1539        }
 1540
 1541        public static void LoadingHUDReadyForTeleport(int x, int y)
 1542        {
 1543            gotoEvent.x = x;
 1544            gotoEvent.y = y;
 1545            SendMessage("LoadingHUDReadyForTeleport", gotoEvent);
 1546        }
 1547
 1548        public static void JumpIn(int x, int y, string serverName, string layerName)
 1549        {
 1550            jumpInPayload.realm.serverName = serverName;
 1551            jumpInPayload.realm.layer = layerName;
 1552
 1553            jumpInPayload.gridPosition.x = x;
 1554            jumpInPayload.gridPosition.y = y;
 1555
 1556            SendMessage("JumpIn", jumpInPayload);
 1557        }
 1558
 1559        public static void JumpInHome(string mostPopulatedRealm)
 1560        {
 1561            jumpInPayload.realm.serverName = mostPopulatedRealm;
 1562            SendMessage("JumpInHome", jumpInPayload);
 1563        }
 1564
 1565        public static void SendChatMessage(ChatMessage message)
 1566        {
 1567            sendChatMessageEvent.message = message;
 1568            SendMessage("SendChatMessage", sendChatMessageEvent);
 1569        }
 1570
 1571        public static void UpdateFriendshipStatus(FriendshipUpdateStatusMessage message) { SendMessage("UpdateFriendship
 1572
 1573        public static void ScenesLoadingFeedback(LoadingFeedbackMessage message) { SendMessage("ScenesLoadingFeedback", 
 1574
 1575        public static void FetchHotScenes() { SendMessage("FetchHotScenes"); }
 1576
 1577        public static void SetBaseResolution(int resolution)
 1578        {
 1579            baseResEvent.baseResolution = resolution;
 1580            SendMessage("SetBaseResolution", baseResEvent);
 1581        }
 1582
 1583        public static void ReportAnalyticsEvent(string eventName) { ReportAnalyticsEvent(eventName, null); }
 1584
 1585        public static void ReportAnalyticsEvent(string eventName, AnalyticsPayload.Property[] eventProperties)
 1586        {
 1587            analyticsEvent.name = eventName;
 1588            analyticsEvent.properties = eventProperties;
 1589            SendMessage("Track", analyticsEvent);
 1590        }
 1591
 1592        public static void FetchBalanceOfMANA() { SendMessage("FetchBalanceOfMANA"); }
 1593
 1594        public static void SendSceneExternalActionEvent(int sceneNumber, string type, string payload)
 1595        {
 1596            sceneExternalActionEvent.type = type;
 1597            sceneExternalActionEvent.payload = payload;
 1598            SendSceneEvent(sceneNumber, "externalAction", sceneExternalActionEvent);
 1599        }
 1600
 1601        public static void SetMuteUsers(string[] usersId, bool mute)
 1602        {
 1603            muteUserEvent.usersId = usersId;
 1604            muteUserEvent.mute = mute;
 1605            SendMessage("SetMuteUsers", muteUserEvent);
 1606        }
 1607
 1608        public static void SendCloseUserAvatar(bool isSignUpFlow)
 1609        {
 1610            closeUserAvatarPayload.isSignUpFlow = isSignUpFlow;
 1611            SendMessage("CloseUserAvatar", closeUserAvatarPayload);
 1612        }
 1613
 1614        // Warning: Use this method only for PEXs non-associated to smart wearables.
 1615        //          For PEX associated to smart wearables use 'SetDisabledPortableExperiences'.
 1616        public static void KillPortableExperience(string portableExperienceId)
 1617        {
 1618            killPortableExperiencePayload.portableExperienceId = portableExperienceId;
 1619            SendMessage("KillPortableExperience", killPortableExperiencePayload);
 1620        }
 1621
 1622        public static void RequestThirdPartyWearables(
 1623            string ownedByUser,
 1624            string thirdPartyCollectionId,
 1625            string context)
 1626        {
 1627            requestWearablesPayload.filters = new WearablesRequestFiltersPayload
 1628            {
 1629                ownedByUser = ownedByUser,
 1630                thirdPartyId = thirdPartyCollectionId,
 1631                collectionIds = null,
 1632                wearableIds = null
 1633            };
 1634
 1635            requestWearablesPayload.context = context;
 1636
 1637            SendMessage("RequestWearables", requestWearablesPayload);
 1638        }
 1639
 1640        public static void SetDisabledPortableExperiences(string[] idsToDisable)
 1641        {
 1642            setDisabledPortableExperiencesPayload.idsToDisable = idsToDisable;
 1643            SendMessage("SetDisabledPortableExperiences", setDisabledPortableExperiencesPayload);
 1644        }
 1645
 1646        public static void RequestWearables(
 1647            string ownedByUser,
 1648            string[] wearableIds,
 1649            string[] collectionIds,
 1650            string context)
 1651        {
 1652            requestWearablesPayload.filters = new WearablesRequestFiltersPayload
 1653            {
 1654                ownedByUser = ownedByUser,
 1655                wearableIds = wearableIds,
 1656                collectionIds = collectionIds,
 1657                thirdPartyId = null
 1658            };
 1659
 1660            requestWearablesPayload.context = context;
 1661
 1662            SendMessage("RequestWearables", requestWearablesPayload);
 1663        }
 1664
 1665        public static void RequestEmotes(
 1666            string ownedByUser,
 1667            string[] emoteIds,
 1668            string[] collectionIds,
 1669            string context)
 1670        {
 1671            requestEmotesPayload.filters = new EmotesRequestFiltersPayload()
 1672            {
 1673                ownedByUser = ownedByUser,
 1674                emoteIds = emoteIds,
 1675                collectionIds = collectionIds,
 1676                thirdPartyId = null
 1677            };
 1678
 1679            requestEmotesPayload.context = context;
 1680
 1681            SendMessage("RequestEmotes", requestEmotesPayload);
 1682        }
 1683
 1684        public static void SearchENSOwner(string name, int maxResults)
 1685        {
 1686            searchEnsOwnerPayload.name = name;
 1687            searchEnsOwnerPayload.maxResults = maxResults;
 1688
 1689            SendMessage("SearchENSOwner", searchEnsOwnerPayload);
 1690        }
 1691
 1692        public static void RequestHomeCoordinates() { SendMessage("RequestHomeCoordinates"); }
 1693
 1694        public static void RequestUserProfile(string userId)
 1695        {
 1696            stringPayload.value = userId;
 1697            SendMessage("RequestUserProfile", stringPayload);
 1698        }
 1699
 1700        public static void ReportAvatarFatalError(string payload) { SendJson("ReportAvatarFatalError", payload); }
 1701
 1702        public static void UnpublishScene(Vector2Int sceneCoordinates)
 1703        {
 1704            var payload = new UnpublishScenePayload() { coordinates = $"{sceneCoordinates.x},{sceneCoordinates.y}" };
 1705            SendMessage("UnpublishScene", payload);
 1706        }
 1707
 1708        public static void NotifyStatusThroughChat(string message)
 1709        {
 1710            stringPayload.value = message;
 1711            SendMessage("NotifyStatusThroughChat", stringPayload);
 1712        }
 1713
 1714        public static void ReportVideoProgressEvent(
 1715            string componentId,
 1716            int sceneNumber,
 1717            string videoClipId,
 1718            int videoStatus,
 1719            float currentOffset,
 1720            float length)
 1721        {
 1722            SendVideoProgressEvent progressEvent = new SendVideoProgressEvent()
 1723            {
 1724                componentId = componentId,
 1725                sceneNumber = sceneNumber,
 1726                videoTextureId = videoClipId,
 1727                status = videoStatus,
 1728                currentOffset = currentOffset,
 1729                videoLength = float.IsInfinity(length) ? float.MaxValue : length
 1730            };
 1731
 1732            SendMessage("VideoProgressEvent", progressEvent);
 1733        }
 1734
 1735        public static void ReportAvatarRemoved(string avatarId)
 1736        {
 1737            avatarStatePayload.type = "Removed";
 1738            avatarStatePayload.avatarShapeId = avatarId;
 1739            SendMessage("ReportAvatarState", avatarStatePayload);
 1740        }
 1741
 1742        public static void ReportAvatarSceneChanged(string avatarId, int sceneNumber)
 1743        {
 1744            avatarSceneChangedPayload.type = "SceneChanged";
 1745            avatarSceneChangedPayload.avatarShapeId = avatarId;
 1746            avatarSceneChangedPayload.sceneNumber = sceneNumber;
 1747            SendMessage("ReportAvatarState", avatarSceneChangedPayload);
 1748        }
 1749
 1750        public static void ReportAvatarClick(int sceneNumber, string userId, Vector3 rayOrigin, Vector3 rayDirection, fl
 1751        {
 1752            avatarOnClickPayload.userId = userId;
 1753            avatarOnClickPayload.ray.origin = rayOrigin;
 1754            avatarOnClickPayload.ray.direction = rayDirection;
 1755            avatarOnClickPayload.ray.distance = distance;
 1756
 1757            SendSceneEvent(sceneNumber, "playerClicked", avatarOnClickPayload);
 1758        }
 1759
 1760        public static void ReportOnPointerHoverEnterEvent(int sceneNumber, string uuid)
 1761        {
 1762            onPointerHoverEnterEvent.uuid = uuid;
 1763            SendSceneEvent(sceneNumber, "uuidEvent", onPointerHoverEnterEvent);
 1764        }
 1765
 1766        public static void ReportOnPointerHoverExitEvent(int sceneNumber, string uuid)
 1767        {
 1768            onPointerHoverExitEvent.uuid = uuid;
 1769            SendSceneEvent(sceneNumber, "uuidEvent", onPointerHoverExitEvent);
 1770        }
 1771
 1772        public static void ReportTime(float time, bool isPaused, float timeNormalizationFactor, float cycleTime)
 1773        {
 1774            timeReportPayload.time = time;
 1775            timeReportPayload.isPaused = isPaused;
 1776            timeReportPayload.timeNormalizationFactor = timeNormalizationFactor;
 1777            timeReportPayload.cycleTime = cycleTime;
 1778            SendMessage("ReportDecentralandTime", timeReportPayload);
 1779        }
 1780
 1781        public static void GetFriendsWithDirectMessages(string userNameOrId, int limit, int skip)
 1782        {
 1783            getFriendsWithDirectMessagesPayload.userNameOrId = userNameOrId;
 1784            getFriendsWithDirectMessagesPayload.limit = limit;
 1785            getFriendsWithDirectMessagesPayload.skip = skip;
 1786            SendMessage("GetFriendsWithDirectMessages", getFriendsWithDirectMessagesPayload);
 1787        }
 1788
 1789        public static void MarkMessagesAsSeen(string userId)
 1790        {
 1791            markMessagesAsSeenPayload.userId = userId;
 1792            SendMessage("MarkMessagesAsSeen", markMessagesAsSeenPayload);
 1793        }
 1794
 1795        public static void GetPrivateMessages(string userId, int limit, string fromMessageId)
 1796        {
 1797            getPrivateMessagesPayload.userId = userId;
 1798            getPrivateMessagesPayload.limit = limit;
 1799            getPrivateMessagesPayload.fromMessageId = fromMessageId;
 1800            SendMessage("GetPrivateMessages", getPrivateMessagesPayload);
 1801        }
 1802
 1803        public static void MarkChannelMessagesAsSeen(string channelId)
 1804        {
 1805            markChannelMessagesAsSeenPayload.channelId = channelId;
 1806            SendMessage("MarkChannelMessagesAsSeen", markChannelMessagesAsSeenPayload);
 1807        }
 1808
 1809        public static void GetUnseenMessagesByUser() { SendMessage("GetUnseenMessagesByUser"); }
 1810
 1811        public static void GetUnseenMessagesByChannel()
 1812        {
 1813            SendMessage("GetUnseenMessagesByChannel");
 1814        }
 1815
 1816        public static void GetFriends(int limit, int skip)
 1817        {
 1818            SendMessage("GetFriends", new GetFriendsPayload
 1819            {
 1820                limit = limit,
 1821                skip = skip
 1822            });
 1823        }
 1824
 1825        public static void GetFriends(string usernameOrId, int limit)
 1826        {
 1827            SendMessage("GetFriends", new GetFriendsPayload
 1828            {
 1829                userNameOrId = usernameOrId,
 1830                limit = limit
 1831            });
 1832        }
 1833
 1834        public static void LeaveChannel(string channelId)
 1835        {
 1836            SendMessage("LeaveChannel", new LeaveChannelPayload
 1837            {
 1838                channelId = channelId
 1839            });
 1840        }
 1841
 1842        public static void CreateChannel(string channelId)
 1843        {
 1844            SendMessage("CreateChannel", new CreateChannelPayload
 1845            {
 1846                channelId = channelId
 1847            });
 1848        }
 1849
 1850        public static void JoinOrCreateChannel(string channelId)
 1851        {
 1852            SendMessage("JoinOrCreateChannel", new JoinOrCreateChannelPayload
 1853            {
 1854                channelId = channelId
 1855            });
 1856        }
 1857
 1858        public static void GetChannelMessages(string channelId, int limit, string fromMessageId)
 1859        {
 1860            SendMessage("GetChannelMessages", new GetChannelMessagesPayload
 1861            {
 1862                channelId = channelId,
 1863                limit = limit,
 1864                from = fromMessageId
 1865            });
 1866        }
 1867
 1868        public static void GetJoinedChannels(int limit, int skip)
 1869        {
 1870            SendMessage("GetJoinedChannels", new GetJoinedChannelsPayload
 1871            {
 1872                limit = limit,
 1873                skip = skip
 1874            });
 1875        }
 1876
 1877        public static void GetChannels(int limit, string since, string name)
 1878        {
 1879            SendMessage("GetChannels", new GetChannelsPayload
 1880            {
 1881                limit = limit,
 1882                since = since,
 1883                name = name
 1884            });
 1885        }
 1886
 1887        public static void GetChannelInfo(string[] channelIds)
 1888        {
 1889            SendMessage("GetChannelInfo", new GetChannelInfoPayload
 1890            {
 1891                channelIds = channelIds
 1892            });
 1893        }
 1894
 1895        public static void GetChannelMembers(string channelId, int limit, int skip, string name)
 1896        {
 1897            SendMessage("GetChannelMembers", new GetChannelMembersPayload
 1898            {
 1899                channelId = channelId,
 1900                limit = limit,
 1901                skip = skip,
 1902                userName = name
 1903            });
 1904        }
 1905
 1906        public static void MuteChannel(string channelId, bool muted)
 1907        {
 1908            SendMessage("MuteChannel", new MuteChannelPayload
 1909            {
 1910                channelId = channelId,
 1911                muted = muted
 1912            });
 1913        }
 1914
 1915        public static void UpdateMemoryUsage()
 1916        {
 1917            SendMessage("UpdateMemoryUsage");
 1918        }
 1919
 1920        public static void RequestAudioDevices() => SendMessage("RequestAudioDevices");
 1921
 1922        public static void SetInputAudioDevice(string inputDeviceId)
 1923        {
 1924            SendMessage(nameof(SetInputAudioDevice), new SetInputAudioDevicePayload()
 1925            {
 1926                deviceId = inputDeviceId
 1927            });
 1928        }
 1929    }
 1930}

Methods/Properties

UUIDEvent()