flathub / net.openra.OpenRA

https://flathub.org/apps/details/net.openra.OpenRA
1 stars 4 forks source link

Discord RPC #21

Closed Mailaender closed 1 year ago

Mailaender commented 1 year ago

See https://github.com/flathub/com.github.Anuken.Mindustry/commit/3307847e9697a862f06ef776fc0b459e8a699daf though I am not sure how to integrate this. Ideally, this should be a first time only script run.

Unrud commented 1 year ago

The symlink /run/user/1000/discord-ipc-0 -> /run/user/1000/app/com.discordapp.Discord/discord-ipc-0 gets created and OpenRA successfully connects to the Unix domain socket but nothing more happens. How can I verify that it actually works? (I don't know anything about Discord.)

Mailaender commented 1 year ago

Start the game. Look at your discord username. It should update the status in the chat client.

Unrud commented 1 year ago

I think the discord integration is broken. It constantly opens the socket discord-ipc-0, then does nothing with it and closes it again.

Open socket

[pid    61] socket(AF_UNIX, SOCK_STREAM, 0)       = 41
[pid    61] setsockopt(41, SOL_SOCKET, SO_REUSEADDR, [1], 4)   = 0
[pid    61] connect(41, {sa_family=AF_UNIX, sun_path="/run/user/1000/discord-ipc-0"}, 31) = 0
[pid    61] fcntl(41, F_SETFD, FD_CLOEXEC) = 0

Do nothing with the socket

[pid    61] pipe([40, 42]) = 0
[pid    61] fcntl(40, F_SETFL, O_RDONLY|O_NONBLOCK) = 0

[pid    61] write(42, "c", 1)        = 1
[pid    62] poll([{fd=40, events=POLLIN}, {fd=41, events=POLLIN}], 2, -1)         = 1 ([{fd=40, revents=POLLIN}])

[pid    62] poll([{fd=40, events=POLLIN}, {fd=41, events=POLLIN}], 2, -1 <unfinished ...>
[pid    61] write(42, "c", 1)        = 1
[pid    62] <... poll resumed>)         = 1 ([{fd=40, revents=POLLIN}])

Close socket

[pid    61] fcntl(41, F_GETFL)          = 0x2 (flags O_RDWR)
[pid    61] fcntl(41, F_SETFL, O_RDWR|O_NONBLOCK)        = 0
[pid    61] shutdown(41, SHUT_RD)     = 0
[pid    61] close(41)        = 0

Repeat ...

Maybe a bug in the old version of DiscordRichPresence? It seems to work with bleed, which uses the latest version.

Mailaender commented 1 year ago

It was first introdcued in https://www.openra.net/news/release-20210321/ but I remember there were followups.

Mailaender commented 1 year ago

Discord also frequently changes API.

Unrud commented 1 year ago

Discord also frequently changes API.

I think the problem is some incompatibility with mono. The later version of DiscordRichPresence still doesn't work with mono but works fine with dotnet.

I am closing this as it now works with the beta branch.