I've been working on a project where I need to implement an auto-logout feature for various game launchers like Steam, Battle.net, and GOG. This functionality is straightforward with most launchers, as simply closing them from the task manager triggers the logout process if the "stay signed in" option isn't checked.
However, I'm facing a challenge with the Epic Games Launcher. Unlike other launchers, simply closing it from the task manager doesn't seem to trigger an automatic logout, even when the "stay signed in" option is unchecked.
I've explored the Epic Games documentation and forums but haven't found a clear solution for this issue. Can anyone provide guidance or suggest a workaround for implementing auto-logout functionality specifically for the Epic Games Launcher?
using System;
using Epic.OnlineServices;
using Epic.OnlineServices.Auth;
using Epic.OnlineServices.Platform;
class Program
{
static void Main(string[] args)
{
try
{
Initialize EOS SDK var initializeOptions = new InitializeOptions();
Epic.OnlineServices.Platform.PlatformInterface.Initialize(ref initializeOptions);
// Create a callback object for logout
var logoutCallback = new Epic.OnlineServices.Auth.OnLogoutCallback((ref LogoutCallbackInfo data) =>
{
// You can handle the logout callback here if needed
if (data.ResultCode == Result.Success)
{
Console.WriteLine("Logged out successfully");
}
else
{
Console.WriteLine("Failed to log out");
Console.WriteLine("Error: " + data.ResultCode);
// Optionally provide more details about the error
}
});
// Create an instance of AuthInterface
var authInterface = new AuthInterface();
// Replace "YOUR_EPIC_ACCOUNT_ID_HERE" with your actual EpicAccountId
var localUserId = EpicAccountId.FromString("71dd7e2e115641eb93e3fb9c49c40e45");
// Log out of the Epic Games account
var logoutOptions = new LogoutOptions();
logoutOptions.LocalUserId = localUserId;
authInterface.Logout(ref logoutOptions, IntPtr.Zero, logoutCallback);
// Shutdown EOS SDK
Epic.OnlineServices.Platform.PlatformInterface.Shutdown();
}
catch (Exception ex)
{
Console.WriteLine("An error occurred: " + ex.Message);
}
}
}