JnCrMx / discord-game-sdk4j

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

Feature Request: Discord instance #65

Closed LakyLuc closed 11 months ago

LakyLuc commented 1 year ago

It woult be nice if I can specify the discord instance at core init for testing: https://discord.com/developers/docs/game-sdk/sdk-starter-guide#testing-locally-with-two-clients

JnCrMx commented 1 year ago

Is this referring to the current master or the java-impl branch?

In the native version that is already possible by setting the environment variable.

In the Java implementation that still needs to be added.

LakyLuc commented 1 year ago

I need it in Java

slava110 commented 1 year ago

IMO it would also be useful to list all available Discord instances (so user could choose one of them for example). Do you think it would be possible, JnCrMx? If it is possible, maybe it would be possible to get name (maybe even icon) of certain Discord instance too? c:

JnCrMx commented 1 year ago

On Windows, I have no idea, because I don't know if there is a way to check if a socket exists (besides connecting to it).

On Linux, you can use this code to determine all possible instances. I think I will also add a way to specify the path to the socket without using environment variables, so you could simply pass the path to the library.

Determining name and icon seems difficult. If you just want to know if it is a Snap/Flatpak/Host installation, you can easily deduce that from the path on Linux (and on Windows it is irrelevant). Determining if it is Release/Beta/Canary is more tricky... On Linux, you could simply use fuser to determine the PID of the Discord process (and then deduce more information from that).

I think providing a portable way of that is very difficult, and I think it is outside the scope of this library (as the original Game SDK also does not offer it). Overall, this feature is more meant as a way of assisting developers rather than to be used by end-users.

slava110 commented 1 year ago

Okay, thank you so much for detailed answer!