Beispiel #1
0
    void OnGUI()
    {
        int left   = 200;
        int width  = 150;
        int height = 30;
        int top    = 70;
        int i      = 0;

        bool initialize       = false;
        bool shutdown         = false;
        bool connect          = false;
        bool connectAnonymous = false;
        bool disconnect       = false;
        bool sendMessage      = false;

        if (m_ChatController.IsInitialized)
        {
            if (m_ChatController.IsConnected(m_Channel))
            {
                if (!m_ChatController.IsAnonymous(m_Channel))
                {
                    sendMessage = GUI.Button(new Rect(left, top + height * i++, width, height), "Send Message");
                }
                disconnect = GUI.Button(new Rect(left, top + height * i++, width, height), "Disconnect");
            }
            else
            {
                connect          = GUI.Button(new Rect(left, top + height * i++, width, height), "Connect");
                connectAnonymous = GUI.Button(new Rect(left, top + height * i++, width, height), "Connect Anonymously");
            }

            shutdown = GUI.Button(new Rect(left, top + height * i++, width, height), "Shutdown");
        }
        else
        {
            initialize = GUI.Button(new Rect(left, top + height * i++, width, height), "Initialize");
        }

        if (connect)
        {
            if (string.IsNullOrEmpty(m_Channel.Trim()))
            {
                m_Channel = m_UserName;
            }

            m_ChatController.Connect(m_Channel);
        }
        else if (connectAnonymous)
        {
            if (string.IsNullOrEmpty(m_Channel.Trim()))
            {
                m_Channel = m_UserName;
            }

            m_ChatController.AuthToken = m_BroadcastController.AuthToken;

            m_ChatController.ConnectAnonymous(m_Channel);
        }
        else if (disconnect)
        {
            m_ChatController.Disconnect(m_Channel);
        }
        else if (sendMessage)
        {
            m_ChatController.SendChatMessage(m_Channel, m_Message);
            m_Message = string.Empty;
        }
        else if (initialize)
        {
            if (m_BroadcastController.AuthToken == null || string.IsNullOrEmpty(m_BroadcastController.AuthToken.Data))
            {
                DebugOverlay.Instance.AddViewportText("Auth token not available");
                return;
            }

            m_ChatController.AuthToken = m_BroadcastController.AuthToken;
            m_ChatController.UserName  = m_UserName;

            m_ChatController.Initialize();
        }
        else if (shutdown)
        {
            m_ChatController.Shutdown();
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        int left   = 200;
        int width  = 150;
        int height = 30;
        int top    = 70;
        int i      = 0;

        bool connect          = false;
        bool connectAnonymous = false;
        bool disconnect       = false;
        bool sendMessage      = false;

        if (m_ChatController.IsInitialized)
        {
            if (m_ChatController.IsConnected)
            {
                if (!m_ChatController.IsAnonymous)
                {
                    sendMessage = GUI.Button(new Rect(left, top + height * i++, width, height), "Send Message");
                }
                disconnect = GUI.Button(new Rect(left, top + height * i++, width, height), "Disconnect");
            }
        }
        else
        {
            connect          = GUI.Button(new Rect(left, top + height * i++, width, height), "Connect");
            connectAnonymous = GUI.Button(new Rect(left, top + height * i++, width, height), "Connect Anonymously");
        }

        if (connect)
        {
            if (string.IsNullOrEmpty(m_Channel.Trim()))
            {
                m_Channel = m_UserName;
            }

            m_ChatController.AuthToken = m_BroadcastController.AuthToken;
            m_ChatController.UserName  = m_UserName;

            m_ChatController.Connect(m_Channel);
        }
        else if (connectAnonymous)
        {
            if (string.IsNullOrEmpty(m_Channel.Trim()))
            {
                m_Channel = m_UserName;
            }

            m_ChatController.AuthToken = m_BroadcastController.AuthToken;

            m_ChatController.ConnectAnonymous(m_Channel);
        }
        else if (disconnect)
        {
            m_ChatController.Disconnect();
        }
        else if (sendMessage)
        {
            m_ChatController.SendChatMessage(m_Message);
            m_Message = string.Empty;
        }
    }