Custom lobby protocol#600
Conversation
p2004a
left a comment
There was a problem hiding this comment.
not looked at all, at high level for sure markdown section looks sensitive and needs attention
|
I abandoned any local testing with local http bride and set up an external service. Everything seems to be working as expected. Details in the edited PR description :) |
|
For future reference while implementing stuff for this, I was able to navigate to a specific map (e.g. the appropriate map-specific // Using https://bar.devopsowy.pl/internal/maps?mapName=AcidicQuarry%205.17
registerLobbyProtocolAction(
"internal",
"maps",
(_url, webContents) => {
if (_url.searchParams.get("mapName")) {
webContents.send("navigation:navigateTo", `/library/maps/${_url.searchParams.get("mapName")}`);
return;
}
webContents.send("navigation:navigateTo", "/library/maps/maps");
},
{ label: "Go to Map(s)" }
);Note: Certain things like lobby/party invites will likely need IPC events added to call the appropriate store methods, since there is some renderer-side work done to both send the request and maintain the UI. |
|
Tested in Linux Mint 22.3 Cinnamon (via VirtualBox) and working also. 👍 |
|
In my opinion, the only question remaining is about this external service for the links. I would prefer that we commit this PR with a relatively permanent location already active. @BElluu there is no license listed for your BAR Lobby Protocol Service so BAR would likely not use it without resolving that question. Obviously, it's not something you should host directly either, so BAR either needs a license to use it or will have to self implement something. @p2004a In Discord you stated the following:
Since this is basically an infrastructure task, do you have any preferences/opinions to add? |
|
@Hectate I added MIT license to external service :) |
| export function buildLobbyProtocolUrl(handler: string, action: string, queryString = ""): string { | ||
| return `${LOBBY_PROTOCOL_PREFIX}${handler}/${action}${queryString}`; | ||
| } | ||
|
|
There was a problem hiding this comment.
While looking over this, I realized that we're basically building the URL string manually. We should use Node's URL class to build this, including the URLSearchParams, and then return the URL instead of the string. From there, the client can handle it as it sees fit (including just putting url.href into the copy/paste buffer for the user). That way if there's ever a need for the actual URL, we don't have to reconstruct it from the string.
And I also just noticed this is not being used at all anywhere except tests. The preload.ts : getShareableUrl code should call this function instead and return the URL. The code there looks good, it just should be moved here. That'll allow us to use it in main the same way we use it in renderer.
Closed #537
I implemented custom lobby protocol handling for
barrts://, so BAR Lobby can react to internal actions and links opened from outside the application, similar to Steam or Spotify.I tested it and protocol works on Windows 11 and Linux Ubuntu 26. I tested build packages like AppImage and just dev (npm start).
The protocol is now supported both from inside the lobby and through external web links handled by a separate protocol service.
Tested and working on:
npm start).exe)npm start)AppImage)What was done:
barrts://internal/test- shows a test notificationbarrts://internal/ping- shows a ping notificationbarrts://internal/replays- navigates to the replays tab.desktop+xdg-mime/gio.External protocol service:
The external service maps web links to
barrts://protocol URLs.Examples:
https://bar.devopsowy.pl/internal/pingopens:
barrts://internal/pinghttps://bar.devopsowy.pl/internal/replaysopens:
barrts://internal/replayshttps://bar.devopsowy.pl/lobby/invite?id=555opens:
barrts://lobby/invite?id=555Why the external service is needed:
barrts://protocol.How to test:
barrts://internal/testbarrts://internal/pingbarrts://internal/replayshttps://bar.devopsowy.pl/internal/testhttps://bar.devopsowy.pl/internal/pinghttps://bar.devopsowy.pl/internal/replaysExpected behavior:
AI / LLM usage statement
I used AI/LLM assistance to research and debug custom protocol handling in Electron, especially platform-specific behavior on Linux, AppImage protocol registration,
.desktophandlers,xdg-mime/gio, and Chromium sandbox issues. I also used it to compare the approach with applications such as Steam and Spotify.