Example #1
0
        public static List <object> GetAvatars()
        {
            List <object> avatars = new List <object>();

            VRCToolsLogger.Info("getAvatars");

            if (!InitConnection())
            {
                return(avatars);
            }

            VRCTRequest request = new VRCTRequest("GET", "");

            VRCTResponse response = RequestSync(request.AsJson());

            if (response.returncode != ReturnCodes.SUCCESS)
            {
                if (response.returncode != ReturnCodes.BANNED_ACCOUNT && response.returncode != ReturnCodes.BANNED_ADDRESS)
                {
                    VRCToolsLogger.Error("Unable to get avatars: error code " + response.returncode);
                }
                return(avatars);
            }

            VRCToolsLogger.Info(response.data);
            List <SerializableApiAvatar> serializedAvatars = SerializableApiAvatar.ParseJson(response.data);

            foreach (SerializableApiAvatar serializedAvatar in serializedAvatars)
            {
                avatars.Add(serializedAvatar.getDictionary());
            }

            return(avatars);
        }
Example #2
0
        public static void Init()
        {
            Thread th = new Thread(() => {
                while (true)
                {
                    Thread.Sleep(2 * 60 * 1000);
                    if (client == null || !client.Connected)
                    {
                        continue;
                    }

                    VRCTRequest request = new VRCTRequest("KEEPALIVE", "");
                    RequestSync(request.AsJson());
                }
            });

            th.IsBackground = true;
            th.Name         = "VRCTools keepalive";
            th.Start();
        }
Example #3
0
        internal static void ShowMOTD()
        {
            if (!InitConnection())
            {
                return;
            }

            VRCTRequest request = new VRCTRequest("GETMOTD", "");

            VRCTResponse response = RequestSync(request.AsJson());

            if (response.returncode == ReturnCodes.SUCCESS)
            {
                string[] motdLines = response.data.Split(new string[] { "<br />" }, StringSplitOptions.None);
                foreach (string line in motdLines)
                {
                    VRCToolsMainComponent.MessageGUI(Color.white, line, 20);
                }
            }
        }
Example #4
0
        public static string GetLastestVersion()
        {
            if (!InitConnection())
            {
                return(VRCToolsMainComponent.VERSION);
            }

            VRCTRequest request = new VRCTRequest("GETVERSION", "");

            VRCTResponse response = RequestSync(request.AsJson());

            if (response.returncode != ReturnCodes.WAITING_FOR_UPDATE && response.data != VRCToolsMainComponent.VERSION)
            {
                if (response.returncode != ReturnCodes.BANNED_ADDRESS && response.returncode != ReturnCodes.BANNED_ACCOUNT)
                {
                    VRCToolsLogger.Warn("Using older version: " + VRCToolsMainComponent.VERSION + " / " + response.data);
                    badVersion = true;
                }
            }
            return(response.data);
        }