< 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:2074
Line coverage:100% (1 of 1)
Covered branches:0
Total branches:0
Covered methods:1
Total methods:1
Method coverage:100% (1 of 1)

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

Methods/Properties

UUIDEvent()