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

Methods/Properties

UUIDEvent()