GW2RPC icon indicating copy to clipboard operation
GW2RPC copied to clipboard

Support for multiple Discord clients

Open SayuShira opened this issue 1 year ago • 2 comments

Hello~

A while ago I looked into the changes required to send the RPC data to my DiscordPBT installation, as well as my normal Discord. Currently, I'm starting two versions of GW2RPC. The normal and a modified installation where i changed this line in rpc.py:

class DiscordRPC:
    def __init__(self, client_id):
        self.ipc_path = r'\\?\pipe\discord-ipc-1'  # Changed 0 to 1

IIRC DiscordRPC can use pipes numbered from 0 to 9- usually, it will use 0 first, then 1, ... As I have two Discord installations, the pipe they use changes depending on which starts faster x.x

From what I understand you moved away from DiscordRPC to the Discord SDK. But as I don't have more knowledge on that or your project, I'm merely asking: Is it- with moderate work to do- possible to support multiple installations from the get-go? As in one GW2RPC open and data sent to all available Discord installations.

Or do you know off the top of your head if I can make changes so that the new SDK version uses a different Discord installation?
It still appears to use the first one I opened - or at least not only the normal Discord client.


And as a side note regarding this.
While making my changes and creating my .exe file, I got errors that the discord_game_sdk.dll file was not found. Copying the DLL into the /dist folder, where I executed my version, solved this. Your zip download however didn't need to include the DLL file separate from the .exe. Honestly no clue why not.
Again, I don't really know much about .spec, but including the DLL into the added files got rid of the error and showed the usual info when in-game. Might be a worthwhile change?

added_files = [("locales", "locales"), ('icon.ico', '.'), ('RPC.ico', '.'), ('lib\\discord_game_sdk.dll', '.')]

Thanks for reading~ not really an expert in any of this, so maybe the questions seem strange, idk. >.<

SayuShira avatar Aug 10 '22 16:08 SayuShira

Hi!

I actually did'nt even know that it is possible to have several discord clients running at the same time, so I never considered it.

From what I understand you moved away from DiscordRPC to the Discord SDK.

Correct! From the Discord GameSDK I found the following here, which describes basically exactly the thing you want to do (Section "Testing Locally with Two Clients"):

// This machine opened Discord Canary first, and Discord PTB second

// This makes the SDK connect to Canary
System.Environment.SetEnvironmentVariable("DISCORD_INSTANCE_ID", "0");
var discord = new Discord(applicationId, Discord.CreateFlags.Default);

// This makes the SDK connect to PTB
System.Environment.SetEnvironmentVariable("DISCORD_INSTANCE_ID", "1");
var discord = new Discord(applicationId, Discord.CreateFlags.Default);

Problem here is that I'm not sure if the wrapper library in python supports those flags, but as it reads an environment variable, it should work? So tl;dr: it could be possible, probably you can find out if you can simply set the DISCORD_INSTANCE_ID as a system wide environment variable? You'd need to have two instances of GW2RPC running still, for now.


I don't really know much about .spec, but including the DLL into the added files got rid of the error and showed the usual info when in-game. Might be a worthwhile change?

I did the exact same thing in building, just forgot to update the build instructions! Will fix soon, ty!

n1tr0-5urf3r avatar Aug 10 '22 16:08 n1tr0-5urf3r

Sorry for the late reply! I will try out the SDK via an environment variable later today. Thank you very much for the help already!


Ah, I see. Thank you for providing them in the first place. I would have been lost without it.
Glad if pointing that out will help someone else.

SayuShira avatar Aug 13 '22 11:08 SayuShira