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

Metrics

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

File(s)

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

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

Methods/Properties

UUIDEvent()