private MessageObject ProcessEmoticonMessage(JsonReader jsonReader) { Debug.Log("ProcessEmoticonMessage"); MessageObject messageObject = new MessageObject(); messageObject.type = ChatMessageTypes.Emoticon; EmoticonData emoticonData = new EmoticonData(); while (jsonReader.Read()) { // Look for data section if (jsonReader.Value != null) { switch (jsonReader.Value.ToString()) { case "source": jsonReader.ReadAsString(); emoticonData.source = jsonReader.Value.ToString() == "builtin" ? EmoticonSource.BuiltIn : EmoticonSource.External; break; case "pack": jsonReader.ReadAsString(); emoticonData.pack = jsonReader.Value.ToString(); break; case "coords": jsonReader.ReadAsString(); emoticonData.coordinates = ProcessCoordinates(jsonReader); break; default: // No-op break; } ; } } messageObject.data = emoticonData; return(messageObject); }
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; }
public EmoticonSet(EmoticonData data, int id) { m_data = data; Id = id; }