Esempio n. 1
0
        public string GetAsync(string url, bool noCache = false, Dictionary <string, object> headers = null)
        {
            string result = null;
            var    thread = ScriptService.CurrentThread;

            Task.Run(() => Get(url, noCache, headers))
            .ContinueWith(t =>
            {
                result = t.Result.ReadString();
                ScriptService.ResumeThread(thread);
            });
            ScriptService.YieldThread();
            return(result);
        }
Esempio n. 2
0
        public string PostAsync(string url, string data,
                                string contentType = "application/json", bool compress = false, Dictionary <string, object> headers = null)
        {
            string result = null;
            var    thread = ScriptService.CurrentThread;

            Task.Run(() => Post(url, data, contentType, compress, headers))
            .ContinueWith(t =>
            {
                result = t.Result;
                ScriptService.ResumeThread(thread);
            });
            ScriptService.YieldThread();
            return(result);
        }
Esempio n. 3
0
        public void PreloadAsync(LuaTable contentUrls)
        {
            var thread = ScriptService.CurrentThread;

            ScriptService.YieldThread();

            var count = contentUrls.Length;
            var tasks = new Task[count];

            for (int i = 0; i < count; i++)
            {
                var contentUrl = (string)contentUrls[count];
                tasks[i] = DownloadStream(contentUrl).ContinueWith(t => Cache(contentUrl, t));
            }

            Task.WhenAll(tasks).ContinueWith(t => ScriptService.ResumeThread(thread));
        }
Esempio n. 4
0
        private LuaTable GetDevices(DataFlow dataFlow)
        {
            var table  = new LuaTable();
            var thread = ScriptService.CurrentThread;

            int i = 0;

            Task.Run(() =>
            {
                using (var enumerator = new MMDeviceEnumerator())
                    foreach (var device in enumerator.EnumAudioEndpoints(dataFlow, DeviceState.Active))
                    {
                        table[i++] = device.FriendlyName;
                    }
            }).ContinueWith(x => ScriptService.ResumeThread(thread));

            ScriptService.YieldThread();

            return(table);
        }
Esempio n. 5
0
        public LuaTable GetClanInfoAsync(uint clanId)
        {
            var thread = ScriptService.CurrentThread;

            var table = new LuaTable();

            Task.Run(() =>
            {
                var steamId = SteamIdFromClanId(clanId);

                var owner = SteamFriends.GetClanOwner(steamId);

                table["Name"]  = SteamFriends.GetClanName(steamId);
                table["Owner"] = new LuaTable
                {
                    ["Name"] = SteamFriends.GetFriendPersonaName(owner),
                    ["Id"]   = owner.GetAccountID().m_AccountID
                };
                table["Tag"]   = SteamFriends.GetClanTag(steamId);
                table["Roles"] = new LuaTable
                {
                    [1] = new LuaTable {
                        [Name] = "Officer",
                    }
                    [2] = new LuaTable {
                        [Name] = "Moderator"
                    }
                    [3] = new LuaTable {
                        [Name] = "Member"
                    }
                };
            }).ContinueWith(x => ScriptService.ResumeThread(thread));

            ScriptService.YieldThread();

            return(table);
        }
Esempio n. 6
0
 internal ScriptService()
 {
     ScriptErrored = new Signal <string, string, Script>(this);
     Service       = this;
 }
Esempio n. 7
0
 public void SetSoundcloudClientId(string clientId)
 {
     ScriptService.AssertIdentity(ScriptIdentity.CoreScript | ScriptIdentity.Editor);
     SoundcloudClientId = clientId;
 }
Esempio n. 8
0
 public void ExecuteScript(string source)
 {
     ScriptService.AssertIdentity(ScriptIdentity.CoreScript);
     throw new NotImplementedException();
 }