NeverDecaf / discord-PWA

A wrapper for the Discord web client as a PWA, made for Chromium browsers on desktop.
MIT License
145 stars 13 forks source link

RPC support? #26

Closed ghost closed 1 year ago

ghost commented 3 years ago

Would it be possible to implement game activity on PWA Discord?

NeverDecaf commented 3 years ago

I'm not even sure if this is possible, but if it is, it would be an insane amount of work to implement. In other words, it's never coming to this PWA. If you need these features I recommend you use the desktop client; this PWA isn't meant to replace the desktop client, just to provide a slightly more usable version of the web client. If you don't want ALL the "features" of the desktop client, I believe you can use BetterDiscord to disable some of them.

LinkofHyrule89 commented 3 years ago

I was actually wondering if it's possible to add to a PWA with the existing APIs or if a new API would need to be created to replicate this functionality. I personally don't care about it but from a developer perspective it would be interesting to know. I imagine it would need extra permissions of sorts to do that.

NeverDecaf commented 3 years ago

I believe you would need to recreate it, unless discord devs left the code in the web version but disabled it. I imagine they don't bundle all the desktop client features into the web version to minimize bandwidth usage. Obviously there's always the option to extract the code from the desktop client but I don't know where to even start with something like that; as I said it would be a monumental effort. The biggest barrier (I think) to getting working RPC is that discord RPC works by hosting a local webserver that applications can send requests to in order to update your status, etc. This is the part that I'm not sure is even possible from within a PWA, it would be like hosting a server in your browser. That being said, it might be possible by utilizing the chrome extension API.

LinkofHyrule89 commented 3 years ago

I mean assuming the code to do it on the Discord side was actually there, I'm just wondering how the PWA would know what applications are running is there a Web API that allows that type of thing? I would think that would be a security issue unless it was specifically allowed by the user.

NeverDecaf commented 3 years ago

Ah, you're thinking of "Game Activity", which is different than RPC. Game activity in the desktop client just uses a process monitor to match against known game process names to show what game the user is currently playing. RPC allows games to directly communicate to discord various status about the game state. Their example: image As for recreating the game activity feature, it should be impossible as webpage javascript is sandboxed and normally has no way of accessing that information.

LinkofHyrule89 commented 3 years ago

Oh interesting, I didn't even know it did that actually! Pretty cool! Seems like one would be required for the other unless the game just has an account link. I know for Xbox it just shows what I'm playing regardless since it's an account link.

LinkofHyrule89 commented 3 years ago

I posted saying they should allow the wco to have a background image or be transparent. You should post on there with any other features you might need and maybe they'll be added. Also, if you want to add me on Discord I'm Link_of_Hyrule#9182.

NonstickAtom785 commented 3 years ago

Since this issue is fairly new, I didn't come hunting for bugs. I actually just came so that I could fork the repo and do some tweaking. That being said I think that RPC is already a thing that Chromium can do. Is it not? I found this information on the official chromium site. AFE RPC Infrastructure

Pretty sure this can be used somehow. I'll have to look into it more closely. I use this application on a Raspberry PI 4. And in case anyone is wondering this app also functions on Chredge and Vivaldi since they are both chromium based web browsers as well.

As for an RPC running like an entire server from chromium, that's not entirely true. Technically all it is, is HTTP requests. So if you wanted to make your own RPC on desktop then yes that would be true. But if you're using an RPC to just connect and retrieve stats from one that is already built then you wouldn't be. It's just requesting HTTP from it and displaying the information in your status. Correct me if I'm wrong if you know better. Thanks.

NeverDecaf commented 3 years ago

Interesting, though it's pretty unclear (to me) what this page is referring to. This looks like information about Chrome(ium) OS, not the browser, and furthermore only for testing purposes, not production use.

However, even if it were possible to hijack a built-in browser RPC (which I highly doubt is possible from an extension context, if it even exists), the issue is that discord's RPC uses specific ports [6463, 6472], so having access to the RPC requests would still be useless unless you could also change the ports it is listening on.

I made the server analogy because it is not as simple as just requesting HTTP, its actually the opposite, you need to listen for incoming HTTP requests and use the results to update your status, the discord client isn't the one initiating the requests (if it were this would actually be possible with plain JS). This, of course, was based on the assumption that you would want to make your own RPC on desktop, which you would, since that is the only way to make this possible.