Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.

Rich Presence#46

Merged
hazzuk merged 21 commits intomasterfrom
rpc
May 1, 2025
Merged

Rich Presence#46
hazzuk merged 21 commits intomasterfrom
rpc

Conversation

@hazzuk
Copy link
Copy Markdown
Member

@hazzuk hazzuk commented May 1, 2025

This pull request adds elecord's first landmark feature, Rich Presence (RPC). 🎉

Rich Presence lets your friends see what you're playing in real time. When enabled, elecord will show your current game to your friends (also displaying it under your profile picture for you to check as well).

To enable sending Rich Presence, you'll need to download the elecord-rpc app. Just follow the simple on-screen instructions to get started. Once installed, elecord-rpc will run automatically as a lightweight background service, detecting the games you play while using elecord.

Basic explanation

RPC in elecord has two major components, the elecord client, and the elecord-rpc (erpc) server. Both of these run locally on the user's computer. And all RPC communication with other users is done over Matrix using room state events.


Changes

USER

src/components/views/spaces/...
SpacePanel.tsx
+ calls <UserRPC .../>

src/components/structures/...
UserRPC.tsx
++ displays user's rpc
++ starts BridgeRPC

src/elecord/rpc/...
BridgeRPC.ts
++ manages rpc server websocket bridge
RouteRPC.ts
++ returns dm room addresses
SendRPC.ts
++ sends state events

ROOMS

src/components/views/rooms/...
RoomTile.tsx
+ provides this.state.isDirectMessage for room tile subtitle
RoomTileSubtitle.tsx
+ calls <RoomTileRPC .../>
RoomTileRPC.tsx
++ displays room tile rpc

src/elecord/rpc/...
ParseRoomRPC.ts
++ manages external state events

Future features

  • Rewrite using MSC4140 Delayed events (critical for large adoption, but not yet enabled on matrix.org)
  • RPC disabled state
  • Temporarily disable RPC for 'this session'
  • Set custom rooms list for sending
  • Send RPC state events to group rooms
  • Set custom applications list for erpc
  • Styling improvements

Warning

There is currently a temporary limit of up to 8 friends to send RPC messages (this is to prevent unintentionally spamming your homeserver with RPC state events). If you're an existing Matrix user with more than eight direct message rooms, I'd currently advise against using elecord until this issue is resolved.

Note

RPC might not always detect your game reliably (especially for new game releases). This is a known issue and game detection will be continuously improved with future updates.

hazzuk added 20 commits March 11, 2025 01:56
The spaces panel will display the users own detected RPC activity. This is to make it clear when elecord has succesfully found the game the user is playing.
The icon now checks the users activity is not null before displaying.
Sends the users calculated activity state event to a Matrix room.
When RPC starts and either can't connect or encounters an error. RPC will continually attempt to reconnect to the erpc app.
As RPC messages are only sent once, we can remove the elapsed time function. As it will be calculated by the client receiving the message instead.
RPC messages will be sent to direct message rooms, routeRPC returns a list of routes to these rooms.
Direct message room tiles now display the relevant user's RPC activity (if any) as a subtitle.
Content of state events can't be trusted, so we need to sanitize them first. Then only display events where the state event key (a user ID) matches the user who sent the state event to prevent impersonation.
Watches for changes to state events inside dm rooms.
Users now send a 'activity.status' value. From this, users can check if an activity received is still valid. And when offline, other users will now display the length of time since the activity was sent.
Sending an expire timestamp provides a unique value to prevent the homeserver from rejecting duplicates of sent events. Additionally, the expire timestamp can be used to determine expired events.
Implemented async for potential performance improvements. Added logging in multiple places for easier debugging.
@hazzuk hazzuk added the enhancement New feature or request label May 1, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 1, 2025

Cloudflare Pages deployment

Latest commit b9871900a50bf6972c0612c43ee24d1e53f8e6e5
Status ✅ Deployed!
URL https://e29c9b4e.elecord-web.pages.dev

@hazzuk hazzuk merged commit a2f589f into master May 1, 2025
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant