Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am also having this issue. I don't think the user is getting set properly. #49

Open
JnCrMx opened this issue Aug 31, 2022 · 5 comments

Comments

@JnCrMx
Copy link
Owner

JnCrMx commented Aug 31, 2022

I am also having this issue. I don't think the user is getting set properly.

[ERROR] Failed to configure networking: ResponseError { code: TransactionAborted, message: "Transaction was aborted" }
Exception in thread "main" de.jcm.discordgamesdk.GameSDKException: Game SDK operation failed: NOT_FOUND
	at de.jcm.discordgamesdk.UserManager.getCurrentUser(UserManager.java:75)
	at Discord.main(Discord.java:19)

Originally posted by @CG-Spectre in #32 (comment)

@JnCrMx
Copy link
Owner Author

JnCrMx commented Aug 31, 2022

The ActivityExample does not use UserManager.getCurrentUser().
Could you please provide part of your code, so I have a chance to replicate this issue?

@CG-Spectre
Copy link

Yes, I will send the whole thing.

import de.jcm.discordgamesdk.Core;
import de.jcm.discordgamesdk.CreateParams;
import de.jcm.discordgamesdk.activity.Activity;

import java.io.File;
import java.io.IOException;
import java.time.Instant;

public class Discord {
    public static void main(String[] args) throws IOException{
        File discordLibrary = DownloadNativeLibrary.downloadDiscordLibrary();
        if(discordLibrary == null){
            System.out.println("Error downloading Discord SDK. Could not initialize Discord RP.");
            return;
        }
        Core.init(discordLibrary);
        try(CreateParams params = new CreateParams()){
            try(Core core = new Core(params)){
                //System.out.println(core.userManager().getUser);
                params.setClientID(1006247841448071269L);
                params.setFlags(CreateParams.getDefaultFlags());
                try(Activity activity = new Activity()) {

                    activity.setDetails("Running an example");
                    activity.setState("and having fun");

                    // Setting a start time causes an "elapsed" field to appear
                    activity.timestamps().setStart(Instant.now());

                    // We are in a party with 10 out of 100 people.

                    activity.party().size().setMaxSize(100);
                    activity.party().size().setCurrentSize(10);

                    // Make a "cool" image show up
                    activity.assets().setLargeImage("discord");
                    activity.assets().setSmallImage("discord");

                    // Setting a join secret and a party ID causes an "Ask to Join" button to appear
                    activity.party().setID("Party!");
                    activity.secrets().setJoinSecret("Join!");

                    // Finally, update the current activity to our activity
                    core.activityManager().updateActivity(activity);
                }
                while(true)
                {
                    core.runCallbacks();
                    try
                    {
                        // Sleep a bit to save CPU
                        Thread.sleep(16);
                    }
                    catch(InterruptedException e)
                    {
                        e.printStackTrace();
                    }
                }
            }

        }
    }
}

I coppied the AcitivityExample

@JnCrMx
Copy link
Owner Author

JnCrMx commented Sep 1, 2022

The code you sent does not call UserManager.getCurrentUser() directly. However, your stracktrace contains a direct call from Discord.main to UserManager.getCurrentUser().
One of them is probably not correct.

@CG-Spectre
Copy link

The code you sent does not call UserManager.getCurrentUser() directly. However, your stracktrace contains a direct call from Discord.main to UserManager.getCurrentUser(). One of them is probably not correct.

I used core.userManager().getCurrentUser() but I get this error:

[ERROR] Failed to configure networking: ResponseError { code: TransactionAborted, message: "Transaction was aborted" }
Exception in thread "main" de.jcm.discordgamesdk.GameSDKException: Game SDK operation failed: NOT_FOUND
	at de.jcm.discordgamesdk.UserManager.getCurrentUser(UserManager.java:75)
	at Discord.main(Discord.java:25)

here is the current code in Discord.java

import de.jcm.discordgamesdk.Core;
import de.jcm.discordgamesdk.CreateParams;
import de.jcm.discordgamesdk.UserManager;
import de.jcm.discordgamesdk.activity.Activity;

import java.io.File;
import java.io.IOException;
import java.time.Instant;

public class Discord {
    public static void main(String[] args) throws IOException{
        File discordLibrary = DownloadNativeLibrary.downloadDiscordLibrary();
        if(discordLibrary == null){
            System.out.println("Error downloading Discord SDK. Could not initialize Discord RP.");
            return;
        }
        Core.init(discordLibrary);
        try(CreateParams params = new CreateParams()){
            try(Core core = new Core(params)){
                params.setClientID(1006247841448071269L);
                params.setFlags(CreateParams.getDefaultFlags());
                try(Activity activity = new Activity()) {
                    System.out.println(core.userManager().getCurrentUser());
                    activity.setDetails("Running an example");
                    activity.setState("and having fun");

                    // Setting a start time causes an "elapsed" field to appear
                    activity.timestamps().setStart(Instant.now());

                    // We are in a party with 10 out of 100 people.

                    activity.party().size().setMaxSize(100);
                    activity.party().size().setCurrentSize(10);

                    // Make a "cool" image show up
                    activity.assets().setLargeImage("discord");
                    activity.assets().setSmallImage("discord");

                    // Setting a join secret and a party ID causes an "Ask to Join" button to appear
                    activity.party().setID("Party!");
                    activity.secrets().setJoinSecret("Join!");

                    // Finally, update the current activity to our activity
                    core.activityManager().updateActivity(activity);
                }
                while(true)
                {
                    core.runCallbacks();
                    try
                    {
                        // Sleep a bit to save CPU
                        Thread.sleep(16);
                    }
                    catch(InterruptedException e)
                    {
                        e.printStackTrace();
                    }
                }
            }

        }
    }
}

@JnCrMx
Copy link
Owner Author

JnCrMx commented Sep 11, 2022

First of all, please set all the required parameters in CreateParams before creating the Core.

Secondly, getCurrentUser() only works after the first onCurrentUserUpdate().
This is what causes the exception. NOT_FOUND also seems to be the correct result for this case.

Please refer to the JavaDoc for more information about that. There is also a section about it in the documentation provided by Discord: https://discord.com/developers/docs/game-sdk/users#getcurrentuser

Before calling this function, you'll need to wait for the OnCurrentUserUpdate callback to fire after instantiating the User manager.

With this library, the User manager is instantiated automatically, so you only need to wait for the onCurrentUserUpdate().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants