Ejemplo n.º 1
0
    void OnGUI()
    {
        if (!waitForKey)
        {
            return;
        }

        Event e = Event.current;

        if (e == null)
        {
            return;
        }

        if (e.isKey || e.isMouse || Input.anyKey)
        {
            var keyCode     = e.keyCode;
            var mouseButton = GetMouseButton();

            if (mouseButton != KeyCode.None)
            {
                keyCode = mouseButton;
            }

            buttonText.text = keyCode.ToString();

            waitForKey          = false;
            button.interactable = true;
            EventSystem.current.SetSelectedGameObject(null);

            OnCode?.Invoke(this, new KeyCodeArgs {
                Code = keyCode
            });
        }
    }
Ejemplo n.º 2
0
        public void ExecuteCode(QuickCode Code)
        {
            IsHandle_ = true;
            Time_     = 0;

            ElementsCount_[(int)Code]++;

            var Total = 0;

            foreach (var Num in ElementsCount_)
            {
                Total += Num;
            }

            if (Total > MaxComposeElementCount)
            {
                ElementsCount_[(int)Code]--;
                Done();
                ExecuteCode(Code);
            }
            else
            {
                OnCode?.Invoke(Code);
                CheckProbe(false);
            }
        }
Ejemplo n.º 3
0
        private async Task GetCodeRoute(HttpContext context)
        {
            try
            {
                if (context.Request.Query.Elements.ContainsKey("error"))
                {
                    var message = context.Request.Query.Elements["error_description"].Replace("+", " ");
                    OnError?.Invoke(this, new CodeErrorArgs {
                        Message = message
                    });
                    await SendHTML(context, "Error", String.Format(DENIED_MESSAGE, $"<i>{message}.</i>"), 401);
                }
                else if (context.Request.Query.Elements.ContainsKey("code"))
                {
                    var code          = context.Request.Query.Elements["code"];
                    var responseState = context.Request.Query.Elements["state"];

                    if (responseState != state)
                    {
                        var message = "Invalid auth state 🤡";
                        OnError?.Invoke(this, new CodeErrorArgs {
                            Message = message
                        });
                        await SendHTML(context, "Error", String.Format(DENIED_MESSAGE, message), 401);
                    }
                    else
                    {
                        OnCode?.Invoke(this, new CodeArgs {
                            Code = code
                        });
                        await SendHTML(context, "Success", SUCCESS_MESSAGE, 200);
                    }
                }

                server.Stop();
                server.Dispose();
                server = null;
            }
            catch (Exception ex)
            {
                Log.Error("HTTP ERROR -> " + ex.ToString());
            }
        }