public void Initiate()
 {
     _server.BroadcastReceived += (msg, reader) =>
     {
         if (msg != Plex.Objects.ServerBroadcastType.Chat_MessageReceived)
         {
             return;
         }
         string author    = reader.ReadString();
         string recipient = reader.ReadString();
         string message   = reader.ReadString();
         _plexgate.Invoke(() =>
         {
             MessageReceived?.Invoke(author, recipient, message);
         });
     };
 }
Esempio n. 2
0
 /// <summary>
 /// Direct the user to the itch.io OAuth login page. This function runs asynchronously and cannot be awaited.
 /// </summary>
 /// <param name="clientId">The itch.io Client ID to use</param>
 /// <param name="onWaitBegin">A function that is called just before the client waits for itch.io to respond. Use this to show any UI that you need to.</param>
 /// <param name="onComplete">A function to be called when the login is complete.</param>
 public void Login(string clientId, Action onWaitBegin, Action onComplete)
 {
     if (LoggedIn)
     {
         return;
     }
     Logger.Log("Starting internal server for callback...");
     Logger.Log("Starting oauth2 request...");
     _entity.Spawn();
     Task.Run(() =>
     {
         string uri = Uri.EscapeDataString("http://localhost:3254/itch_callback");
         Process.Start("https://itch.io/user/oauth?client_id=17a4b2de3caf06c14a524936d88402c1&scope=profile%3Ame&response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A3254%2Fitch_callback");
         string token = (_callbackSrv as ItchOAuthCallbackServer).WaitForToken();
         if (_token != null)
         {
             _token = token;
             _config.SetValue("itch.apikey", _token);
             _config.SaveToDisk(); fetchUserData();
             fetchUserData();
         }
         _plebgate.Invoke(_entity.Despawn);
     });
 }