JnCrMx / discord-game-sdk4j

Java bindings for Discord's Game SDK
MIT License
122 stars 23 forks source link

Failed to configure networking: ResponseError { code: TransactionAborted, message: "Transaction was aborted" } #66

Closed xxAROX closed 1 year ago

xxAROX commented 1 year ago

My Discord is running

Logs:

[ERROR] Failed to configure networking: ResponseError { code: TransactionAborted, message: "Transaction was aborted" }
de.jcm.discordgamesdk.GameSDKException: Game SDK operation failed: TRANSACTION_ABORTED
    at de.jcm.discordgamesdk.Core.lambda$static$0(Core.java:386)
    at de.jcm.discordgamesdk.Core.destroy(Native Method)
    at de.jcm.discordgamesdk.Core.close(Core.java:628)
    at xxAROX.PresenceMan.Application.Bootstrap.lambda$main$0(Bootstrap.java:24)
    at java.base/java.lang.Thread.run(Thread.java:833)

My code:

Bootstrap.java

public static void main(String[] args) {
        new App();
        new Thread(() -> {
            try {
                Core.initDownload();
                try (CreateParams params = new CreateParams()) {
                    params.setClientID(AppInfo.discord_application_id);
                    params.setFlags(CreateParams.getDefaultFlags());
                    try (Core core = new Core(params)) {
                        App.setDiscordCreateParams(params);
                        App.setDiscordCore(core);
                        System.out.println("Discord is initialized!");
                        while (true) {
                            if (core.isOpen()) App.getDiscord_core().runCallbacks();
                            try {
                                Thread.sleep(16);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    } catch (GameSDKException e) {
                        e.printStackTrace();
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }).start();
    }

App.java:

    public static void setDiscordCore(Core discord_core) {
        App.discord_core = discord_core;
        discord_core.activityManager().updateActivity(APIActivity.none().toDiscord());
        for (Consumer<Core> discord_core_listener : discordInitHandlers) discord_core_listener.accept(discord_core);
    }

    public static void setDiscordCreateParams(CreateParams discord_create_params) {
        App.discord_create_params = discord_create_params;
    }

ApiActivity.java

    public Activity toDiscord() {
        Activity activity = new Activity();
        activity.setType(type.toDiscordType());
        activity.setState(network != null ? network : "");
        activity.setDetails(server != null ? server : "");
        if (start != null) activity.timestamps().setStart(Instant.ofEpochMilli(start));
        if (end != null) activity.timestamps().setEnd(Instant.ofEpochMilli(end));
        if (large_icon_key != null) activity.assets().setLargeImage(large_icon_key);
        if (large_icon_text != null) activity.assets().setLargeText(large_icon_text);
        if (small_icon_key != null) activity.assets().setSmallImage(small_icon_key);
        if (small_icon_text != null) activity.assets().setSmallText(small_icon_text);
        if (party_player_count != null) activity.party().size().setCurrentSize(party_player_count);
        if (party_max_player_count != null) activity.party().size().setMaxSize(party_max_player_count);
        return activity;
    }

    public static APIActivity none() {
        var activity = new APIActivity();
        activity.setState("");
        activity.setDetails("");
        activity.setLarge_icon_key("launcher");
        activity.setStart(Instant.now().toEpochMilli());
        return activity;
    }
xxAROX commented 1 year ago

For the first times it worked and it shows the Activity, but since yesteday no longer.

xxAROX commented 1 year ago

Now it works, this is making me crazy