Exemple #1
0
        private void OnLoginButtonPressed()
        {
            //      Log.Info("Login initiated...");

            LoginButton.Enabled = false;

            var profileManager = GetService <ProfileManager>();

            XboxAuthService.OpenBrowser(ConnectResponse.verification_uri);

            if (Clipboard.IsClipboardAvailable())
            {
                try
                {
                    Clipboard.SetText(ConnectResponse.user_code);
                }
                catch (Exception ex)
                {
                    Log.Warn(ex, $"Could not set keyboard contents!");
                }
            }

            //   Log.Info($"Browser opened...");
            AuthenticationService.DoDeviceCodeLogin(GetService <ResourceManager>().DeviceID, ConnectResponse.device_code, CancellationToken.Token).ContinueWith(
                (task) =>
            {
                try
                {
                    var result = task.Result;
                    if (result.success)
                    {
                        var r = AuthenticationService.DecodedChain.Chain.FirstOrDefault(x =>
                                                                                        x.ExtraData != null && !string.IsNullOrWhiteSpace(x.ExtraData.Xuid));

                        var profile = new PlayerProfile(r.ExtraData.Xuid, r.ExtraData.DisplayName,
                                                        r.ExtraData.DisplayName,
                                                        new Skin()
                        {
                            Slim    = true,
                            Texture = null
                        }, result.token.AccessToken,
                                                        JsonConvert.SerializeObject(result.token),
                                                        "xbox");

                        profileManager.CreateOrUpdateProfile("xbox", profile, true);
                        Ready?.Invoke(profile);

                        //Log.Info($"Continuewith Success!");
                    }
                    else
                    {
                        //Log.Info($"Continuewith fail!");
                    }
                }
                catch (Exception ex)
                {
                    Log.Warn($"Authentication issue: {ex.ToString()}");
                }
            });
        }
Exemple #2
0
        public async void Monitor()
        {
            while (IsRunning)
            {
                await Task.Delay(100);

                if (!IsRunning)
                {
                    break;
                }

                var count = CandidateStore.GetCount(MatchSet.Id);
                if (count == MatchSet.Capacity)
                {
                    Ready?.Invoke(MatchSet);
                }
                else if (count % 2 == 0)
                {
                    Ready?.Invoke(MatchSet);
                }
                else
                {
                    NotReady?.Invoke(MatchSet);
                }
            }
        }
Exemple #3
0
        private Task ReadyHandler()
        {
            EmitLogs(LogLevel.Info, "LavalinkClient succesfully initialized");
            Ready?.Invoke();

            return(Task.CompletedTask);
        }
 protected void FireReady(object sender)
 {
     if (Ready != null)
     {
         Ready.Invoke(sender, null);
     }
 }
Exemple #5
0
 protected virtual void OnReady()
 {
     if (Ready != null)
     {
         Ready.Invoke(this, System.EventArgs.Empty);
     }
 }
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            FormRelationshipGoals formRelationshipGoals = new FormRelationshipGoals();

            formRelationshipGoals.Show();
            if (!SQLHandler.Check(Settings.Default.SQL_Server_Address, Settings.Default.SQL_Server_Schema, Settings.Default.SQL_Server_Login, Settings.Default.SQL_Server_Password))
            {
                MessageBox.Show(formRelationshipGoals, "Your SQL settings are not valid! Please provide valid SQL settings in the following window.");
                FormSettings formSettings = new FormSettings();
                formSettings.ShowDialog(formRelationshipGoals);
                while (formSettings.Visible) //Wait until valid settings have been provided before building ServiceProvider
                {
                    Thread.Sleep(1000);
                }
            }
            SQLHandler.Use(new SQLHandler(Settings.Default.SQL_Server_Address, Settings.Default.SQL_Server_Schema, Settings.Default.SQL_Server_Login, Settings.Default.SQL_Server_Password));

            BuildServiceProvider();

            BootAnimation.Play();
            Ready.Invoke();
            Application.Run(formRelationshipGoals);
        }
 private void AsyncNotifyReady()
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             try
             {
                 if (RefreshFunctionListOnReady)
                 {
                     RefreshFunctions();
                 }
                 if (RefreshVariableListOnReady)
                 {
                     RefreshVariables();
                 }
             }
             finally
             {
                 try { Ready?.Invoke(this, EventArgs.Empty); }
                 catch { }
             }
         }
         catch (Exception ex)
         {
             RaiseInternalError(ex);
         }
     });
 }
Exemple #8
0
        private async void Create()
        {
            OutputDevices = await DeviceInformation.FindAllAsync(MediaDevice.GetAudioRenderSelector());

            var settings = new AudioGraphSettings(AudioRenderCategory.Media)
            {
                QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency
            };

            var audioGraphResult = await AudioGraph.CreateAsync(settings);

            if (audioGraphResult.Status != AudioGraphCreationStatus.Success)
            {
                throw new ApplicationException($"Audio graph error: {audioGraphResult.Status}");
            }

            Graph = audioGraphResult.Graph;
            Graph.QuantumProcessed += (audioGraph, e) => AudioGraphQuantumProcessed();
            Graph.QuantumStarted   += (audioGraph, e) => AudioGraphQuantumStarted();

            InputDevice = await CreateInputDevice().ConfigureAwait(true);

            OutputDevice = await CreateOutputDevice().ConfigureAwait(true);

            RecordingOutputNode = CreateFrameOutputNode();

            Ready?.Invoke(this, EventArgs.Empty);
        }
Exemple #9
0
        /// <summary>
        /// Initializes FadeProxy on top of specified AxShockwaveFlash control.
        /// </summary>
        /// <param name="flashControl">AxShockwaveFlash control that contains Fade compatible SWF file.</param>
        public FadeProxy(AxShockwaveFlashObjects.AxShockwaveFlash flashControl)
        {
            proxy = new ExternalInterfaceProxy(flashControl);

            proxy.ExternalInterfaceCall += (s, e) =>
            {
                switch (e.FunctionCall.FunctionName)
                {
                case "checkStatus":
                    return(true);

                case "callbacksReady":
                    Ready?.Invoke(this, EventArgs.Empty);
                    return(null);

                case "stageOneInitialized":
                    _clients[(string)e.FunctionCall.Arguments[0]]?.HandleCall(e);
                    return(null);

                default:
                    Console.WriteLine(e.FunctionCall.FunctionName);
                    return(null);
                }
            };
        }
        private void RenderLoop()
        {
            running = true;
            Ready?.Invoke();

            while (running)
            {
                if (EventsPending())
                {
                    HandleEvents();
                }

                foreach (var area in areas)
                {
                    area.Update();
                }

                lock (chores)
                {
                    if (chores.Count > 0)
                    {
                        RunChores();
                    }
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(NameT.Text))
            {
                MessageBox.Show("名前を入力してください", null, MessageBoxButton.OK);
                return;
            }

            string path = (string)Navigate.Parameters[Constants.NavMusicFileKey];

            switch (difficulty)
            {
            case Difficulty.Easy:
                path = path.Replace(".sgsong", Constants.EasySgSongName);
                break;

            case Difficulty.Normal:
                path = path.Replace(".sgsong", Constants.NormalSgSongName);
                break;
            }
            Navigate.Parameters[Constants.NavMusicFileKey] = path;
            Navigate.Parameters[Constants.NavMusicKey]     = SugaEngine.Export.Notes.Deserialize(path);
            Navigate.Parameters[Constants.NavDifficulty]   = difficulty;

            string fname = System.IO.Path.GetFileName(path);
            string uname = NameT.Text.TrimStart(' ', ' ').TrimEnd(' ', ' ');

            Navigate.Parameters[Constants.NavSgSongPath]  = fname;
            Navigate.Parameters[Constants.NavUserNameKey] = uname;

            if (difficulty.HasValue)
            {
                Ready?.Invoke(this, new DifficultyEventArgs(difficulty.Value));
            }
        }
 private void ChooseListOfYourCards_Resize(object sender, EventArgs e)
 {
     label2.Location = new Point(this.Width / 2 - label2.Width / 2, label2.Height / 4);
     Cards.Location  = new Point(this.Width / 2 - Cards.Width / 2, label2.Height / 4 + label2.Height);
     Ready.Location  = new Point(this.Width / 2 - Ready.Width / 2, label2.Height / 4 + label2.Height + Cards.Height);
     if (count < 15)
     {
         if (Ready.InvokeRequired)
         {
             Ready.Invoke((MethodInvoker)(() => Ready.Visible = false));
         }
         else
         {
             Ready.Visible = false;
         }
     }
     else
     if (count == 15)
     {
         if (Ready.InvokeRequired)
         {
             Ready.Invoke((MethodInvoker)(() => Ready.Visible = true));
         }
         else
         {
             Ready.Visible = true;
         }
     }
 }
        /// <summary>
        /// Called when this RpcSession is connected to the socket.
        /// </summary>
        protected override void OnConnected()
        {
            // If this is a new session on the server, send the welcome message.
            if (BaseSocket.Mode == SocketMode.Server)
            {
                Server.ServerInfo.RequireAuthentication = Config.RequireAuthentication;

                var serializer = SerializationCache.Get();

                serializer.MessageWriter.Write((byte)MqCommandType.RpcCommand);
                serializer.MessageWriter.Write((byte)RpcCommandType.WelcomeMessage);
                serializer.SerializeToWriter(Server.ServerInfo);

                var message = serializer.MessageWriter.ToMessage(true);

                message[0].FrameType = MqFrameType.Command;

                // RpcCommand:byte; RpcCommandType:byte; RpcServerInfoDataContract:byte[];
                Send(message);
            }

            base.OnConnected();

            // If the server does not require authentication, alert the server session that it is ready.
            if (BaseSocket.Mode == SocketMode.Server && Config.RequireAuthentication == false)
            {
                Authenticated = true;
                Ready?.Invoke(this, new SessionEventArgs <TSession, TConfig>((TSession)this));
            }
        }
        internal /* for testing */ void HandleOutputDataReceived(string data)
        {
            if (data == null)
            {
                return;
            }

            if (IsVerbose())
            {
                WritelnToPane(data);
            }

            if (data.Contains("Server started"))
            {
                bool succeeded = false;
                SafeOperation(() =>
                {
                    CreateChannelAndStreamLogs();
                    Ready?.Invoke(this, EventArgs.Empty);
                    succeeded = true;
                });

                if (!succeeded)
                {
                    this.SafeInternalStop();
                }
            }
        }
Exemple #15
0
        protected async Task Login()
        {
            await WriteLine("PASS " + Token + "\r\nNICK " + Nick + "\r\n");

            var resultCode = 0;

            while (resultCode != _successCode)
            {
                var buffer = await _input.ReadLineAsync();

                int.TryParse(buffer?.Split()[1], out resultCode);
                if (buffer == null || IsFailure(buffer))
                {
                    throw new InvalidOrWrongTokenException();
                }
                else if (resultCode == 001)
                {
                    if (ChannelName != null)
                    {
                        await WriteLine($"JOIN {ChannelName}");
                    }

                    if (Ready != null)
                    {
                        await Ready.Invoke();
                    }

                    _logger.LogInformation("Connected.");
                }
            }
        }
        protected override TSession CreateSession(System.Net.Sockets.Socket sessionSocket)
        {
            var session = base.CreateSession(sessionSocket);

            session.Ready        += (sender, e) => { Ready?.Invoke(sender, e); };
            session.Authenticate += (sender, e) => { Authenticate?.Invoke(sender, e); };
            return(session);
        }
Exemple #17
0
 public void Run(int milleseconds)
 {
     Task.Run(async() =>
     {
         await Task.Delay(milleseconds);
         Ready?.Invoke(this, EventArgs.Empty);
     });
 }
Exemple #18
0
 private static async Task Client_ReadyAsync()
 {
     if (!string.IsNullOrEmpty(Playing))
     {
         await SetGameAsync(Playing);
     }
     Ready?.Invoke(client, new EventArgs());
 }
 internal void SetHexEdit(HexEdit hexEdit)
 {
     _editor = hexEdit;
     _editor.BytesPerLine        = BytesPerLine;
     _editor.Buffer.SizeChanged += _editor_SizeChanged;
     Ready?.Invoke(this, EventArgs.Empty);
     _editor.CaretPositionChanged += _editor_CaretPositionChanged;
 }
 private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
 {
     if (!e.IsLoading)
     {
         Ready?.Invoke(this, EventArgs.Empty);
         browser.LoadingStateChanged -= browser_LoadingStateChanged;
     }
 }
        // Logs in using email and password
        public async void Login(string email, string password, string code)
        {
            client.DefaultRequestHeaders.Remove("Referer");
            client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/login");

            var log = new LoginRequest(email, password);

            var content = new JsonContent(log);

            var response = await client.PostAsync(DiscordAPI.loginEndpoint, content);

            var ree = await response.Content.ReadAsStringAsync();

            var responseObject = Serializer.Parse <LoginPayload>(ree);

            client.DefaultRequestHeaders.Remove("Referer");
            if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                if (responseObject.Errors != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Wrong email or password"));
                }
                if (responseObject.CaptchaKey != null)
                {
                    LoginError?.Invoke(new LoginErrorEventArgs(this, "Log in and out of Discord and solve the captcha."));
                }
            }
            else if (response.IsSuccessStatusCode)
            {
                if (string.IsNullOrEmpty(responseObject.Token))
                {
                    if (!string.IsNullOrEmpty(responseObject.Ticket))
                    {
                        client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/login");
                        // Adds a delay so we don't get ratelimited
                        //await Task.Delay(1500);
                        LoginMfa(responseObject.Ticket, code);
                    }
                    else
                    {
                        LoginError?.Invoke(new LoginErrorEventArgs(this, "Unknown error"));
                        Debug.WriteLine("Unknown error");
                    }
                }
                else
                {
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(responseObject.Token);
                    client.DefaultRequestHeaders.Add("Referer", "https://discordapp.com/channels/@me");
                    DataStore.SaveToken(responseObject.Token);
                    Ready?.Invoke(new ReadyEventArgs(this));
                }
            }
            else
            {
                LoginError?.Invoke(new LoginErrorEventArgs(this, "Error " + response.StatusCode));
                Debug.WriteLine("Error " + response.StatusCode);
            }
        }
 private void CharateristicReady()
 {
     --UninitialisedServices;
     if (UninitialisedServices == 0)
     {
         Debug.WriteLine("Characteristics finished setting up : " + Id);
         Ready?.Invoke();
     }
 }
        private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
        {
            IFrame frame = e.Frame;

            if (frame.IsMain && executeOnUrl(frame.Url))
            {
                Ready?.Invoke(this, new PluginDispatchEventArgs(executor));
            }
        }
Exemple #24
0
    private IEnumerator Start()
    {
        while (SteamVR.initializedState == SteamVR.InitializedStates.None || SteamVR.initializedState == SteamVR.InitializedStates.Initializing)
        {
            yield return(null);
        }

        ready.Invoke(SteamVR.instance != null);
    }
Exemple #25
0
        IEnumerator Start()
        {
            //Wait for Localisation to load
            yield return(LocalizationSettings.InitializationOperation);

            AssignLanguages();

            Ready?.Invoke(this, EventArgs.Empty);
        }
Exemple #26
0
 private void ServiceReady()
 {
     --UninitialisedServices;
     if (UninitialisedServices == 0)
     {
         Ready?.Invoke(this);
         Ready = null;
     }
 }
 private void ServiceReady()
 {
     --UninitialisedServices;
     if (UninitialisedServices == 0)
     {
         Debug.WriteLine("Services finished setting up : " + Id);
         Ready?.Invoke();
     }
 }
Exemple #28
0
        public Task NotifyReady()
        {
            if (Ready != null)
            {
                return(Ready.Invoke());
            }

            return(Task.CompletedTask);
        }
Exemple #29
0
        private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)
        {
            IFrame frame = e.Frame;

            if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame))
            {
                Ready?.Invoke(this, new PluginDispatchEventArgs(executor));
            }
        }
 private void cardsFormCLick(object sender, EventArgs e)
 {
     if (count != 15)
     {
         CardsForm card = (CardsForm)sender;
         if (card.ISPRESSED == false)
         {
             card.BackgroundImage = Resource1.ВЫБРАННАЯКАРТА;
             foreach (CardHeroes a in allcards)
             {
                 if (card.NameCards == a.Name)
                 {
                     koloda.Add(a);
                     count++;
                     card.ISPRESSED = true;
                 }
             }
         }
         else
         {
             card.BackgroundImage = Resource1.ФОН_ЛИСТА;
             foreach (CardHeroes a in allcards)
             {
                 if (card.NameCards == a.Name)
                 {
                     count--;
                     card.ISPRESSED = false;
                     koloda.Remove(a);
                 }
             }
         }
         if (count < 15)
         {
             if (Ready.InvokeRequired)
             {
                 Ready.Invoke((MethodInvoker)(() => Ready.Visible = false));
             }
             else
             {
                 Ready.Visible = false;
             }
         }
         else
         if (count == 15)
         {
             if (Ready.InvokeRequired)
             {
                 Ready.Invoke((MethodInvoker)(() => Ready.Visible = true));
             }
             else
             {
                 Ready.Visible = true;
             }
         }
     }
 }