Beispiel #1
0
        async void LoadAsyncData()
        {
            var connectTask = Connect(m_channelName);

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            m_cache = System.IO.Path.Combine(path, "TwitchChat");

            var task = TwitchApi.GetEmoticonData(m_cache);

            GetChannelData();

            Emoticons = await task;
            m_channel = await connectTask;
        }
Beispiel #2
0
        public static async Task <EmoticonData> GetEmoticonData(string cache)
        {
            string url = @"https://api.twitch.tv/kraken/chat/emoticons";
            TwitchEmoticonResponse emotes = null;

            for (int i = 0; i < 3 && emotes == null; i++)
            {
                try
                {
                    var req = (HttpWebRequest)HttpWebRequest.Create(url);
                    req.UserAgent = "TwitchChat Client";

                    var response = await req.GetResponseAsync();

                    var fromStream = response.GetResponseStream();

                    StreamReader reader = new StreamReader(fromStream);

                    emotes = JsonConvert.DeserializeObject <TwitchEmoticonResponse>(reader.ReadToEnd());
                }
                catch (Exception e)
                {
                    Log.Instance.WebApiError(url, e.ToString());
                }

                if (emotes == null)
                {
                    await Task.Delay(30000);
                }
            }

            var data = new EmoticonData(emotes, cache);

            data.DefaultEmoticons.DownloadAll();

            return(data);
        }
Beispiel #3
0
 public EmoticonSet(EmoticonData data, int id)
 {
     m_data = data;
     Id     = id;
 }
        async void LoadAsyncData()
        {
            var connectTask = Connect(m_channelName);

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            m_cache = System.IO.Path.Combine(path, "TwitchChat");

            var task = TwitchApi.GetEmoticonData(m_cache);
            GetChannelData();

            Emoticons = await task;
            m_channel = await connectTask;
        }