예제 #1
0
        IEnumerator Start()
        {
            m_Broadcaster = new Broadcaster(m_TwitchIRC.messenger.channel, m_ClientId);

            while (enabled)
            {
                WWW www = new WWW(m_Broadcaster.url.chatters);

                yield return(www);

                string rawResult = System.Text.Encoding.UTF8.GetString(www.bytes);
                string result    = rawResult.Replace("\n", "").Replace("\r", "").Replace(" ", "");

                TwitchTv.TMI twitchTMI = null;
                try
                {
                    twitchTMI  = m_Broadcaster.ParseJsonChatters(result);
                    m_Chatters = twitchTMI.chatters;
                    if (TwitchConnect.OnRefreshed != null)
                    {
                        TwitchConnect.OnRefreshed.Invoke(m_TwitchIRC, twitchTMI);
                    }
                }
                catch (Exception ex)
                {
                    if (m_DebugLog)
                    {
                        Debug.LogFormat(JSON_EXECPTION_MESSAGE, ex.Message, m_RefreshDelay);
                    }
                }
                yield return(new WaitForSeconds(m_RefreshDelay));
            }
        }
예제 #2
0
        void TwitchConnect_OnRefreshed(TwitchChat twitchIRC, TwitchTv.TMI twitchTvTMI)
        {
            if (twitchTvTMI == null)
            {
                Debug.LogFormat("twitchTvTMI is still null {0}", DateTime.Now);
            }
            //string moderators = string.Join(", ", twitchTvTMI.chatters.moderators);
            //string viewers = string.Join(", ", twitchTvTMI.chatters.viewers);
            //Debug.LogFormat("moderators:{0} viewers:{1} > {2}", moderators, viewers, DateTime.Now);

            foreach (var item in twitchTvTMI.chatters.viewers.Concat(twitchTvTMI.chatters.moderators))
            {
                if (m_Viewers.ContainsKey(item))
                {
                    m_Viewers[item].lifeTime = 0.0f;
                }
            }
            StartCoroutine(CheckForFollowers(twitchTvTMI.chatters.viewers.Concat(twitchTvTMI.chatters.moderators).ToArray()));
        }