示例#1
0
        public virtual bool Initialize()
        {
            if (m_ChatState != ChatState.Uninitialized)
            {
                return(false);
            }

            SetChatState(ChatState.Initializing);

            ErrorCode ret = m_CoreApi.Initialize(ClientId, null);

            if (Error.Failed(ret))
            {
                SetChatState(ChatState.Uninitialized);

                String err = Error.GetString(ret);
                ReportError(String.Format("Error initializing Twitch sdk: {0}", err));

                return(false);
            }

            // initialize chat
            m_ActiveEmoticonMode = this.EmoticonParsingMode;

            TTV_ChatTokenizationOption tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_NONE;

            switch (m_ActiveEmoticonMode)
            {
            case EmoticonMode.None:
                tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_NONE;
                break;

            case EmoticonMode.Url:
                tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_URLS;
                break;

            case EmoticonMode.TextureAtlas:
                tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_TEXTURES;
                break;
            }

            // kick off the async init
            ret = m_ChatApi.Initialize(tokenizationOptions, m_ChatAPIListener);
            if (Error.Failed(ret))
            {
                m_CoreApi.Shutdown();
                SetChatState(ChatState.Uninitialized);

                String err = Error.GetString(ret);
                ReportError(String.Format("Error initializing Twitch chat: %s", err));

                return(false);
            }
            else
            {
                SetChatState(ChatState.Initialized);
                return(true);
            }
        }
示例#2
0
        public virtual bool Initialize()
        {
            if (m_ChatState != ChatState.Uninitialized)
            {
                return false;
            }

            SetChatState(ChatState.Initializing);

            ErrorCode ret = m_Core.Initialize(ClientId, null);
            if (Error.Failed(ret))
            {
                SetChatState(ChatState.Uninitialized);

                String err = Error.GetString(ret);
                ReportError(String.Format("Error initializing Twitch sdk: {0}", err));

                return false;
            }

            // initialize chat
            m_ActiveEmoticonMode = this.EmoticonParsingMode;

            TTV_ChatTokenizationOption tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_NONE;
            switch (m_ActiveEmoticonMode)
            {
                case EmoticonMode.None:
                    tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_NONE;
                    break;
                case EmoticonMode.Url:
                    tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_URLS;
                    break;
                case EmoticonMode.TextureAtlas:
                    tokenizationOptions = TTV_ChatTokenizationOption.TTV_CHAT_TOKENIZATION_OPTION_EMOTICON_TEXTURES;
                    break;
            }

            // kick off the async init
            ret = m_Chat.Initialize(tokenizationOptions, m_ChatAPIListener);
            if (Error.Failed(ret))
            {
                m_Core.Shutdown();
                SetChatState(ChatState.Uninitialized);

                String err = Error.GetString(ret);
                ReportError(String.Format("Error initializing Twitch chat: %s", err));

                return false;
            }
            else
            {
                SetChatState(ChatState.Initialized);
                return true;
            }
        }
示例#3
0
        protected virtual bool Initialize(string channel)
        {
            if (m_ChatInitialized)
            {
                return false;
            }

            m_ActiveEmoticonMode = m_EmoticonMode;
            ErrorCode ret = m_Chat.Initialize(channel, m_ActiveEmoticonMode != EmoticonMode.None);
            if (Error.Failed(ret))
            {
                string err = Error.GetString(ret);
                ReportError(string.Format("Error initializing chat: {0}", err));

                FireDisconnected();

                return false;
            }
            else
            {
                m_Chat.ChatCallbacks = this;
                m_ChatInitialized = true;
                m_ChatState = ChatState.Initialized;

                return true;
            }
        }