< Summary

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

Metrics

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

File(s)

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

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

Methods/Properties

ControlEvent(System.String, T)