Skip to content

kramerc/presence-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

presence-switch

A Discord Rich Presence IPC proxy that multiplexes RPC messages across multiple Discord instances.

What it does

presence-switch sits between Discord RPC client applications (games, media players, etc.) and running Discord instances. It binds the first available discord-ipc-{0..9} socket (preferring discord-ipc-0) and relays all incoming RPC messages to every other existing Discord IPC socket.

This means a single RPC client can broadcast its presence to multiple Discord clients simultaneously.

How it works

graph LR
    A["RPC Client<br/>(e.g. game)"] --> B["presence-switch<br/>(discord-ipc-0)"]
    B --> C["Discord #1"]
    B --> D["Discord #2"]
    B --> E["Discord #N"]
Loading
  1. The switch claims an available discord-ipc-* socket name
  2. RPC clients connect to the switch thinking it's Discord
  3. The switch relays messages to all real Discord instances on other sockets

The IPC binary protocol uses a simple format: 4-byte LE opcode + 4-byte LE length + UTF-8 JSON payload. The switch processes handshake, ping, and close opcodes directly, and forwards all other opcodes (frame, pong) to Discord.

Requirements

  • Rust (edition 2024)
  • One or more running Discord instances

Building

cargo build --release

Usage

  1. Close Discord or ensure discord-ipc-0 is not taken
  2. Run presence-switch:
    cargo run --release
  3. Start your Discord instances β€” they will claim discord-ipc-1, discord-ipc-2, etc.
  4. Launch your RPC-enabled application β€” it connects to presence-switch on discord-ipc-0, which relays to all Discord instances

For best results, start presence-switch before any Discord instances so it can claim discord-ipc-0, which is what most RPC clients connect to by default.

Press Ctrl+C to shut down gracefully.

Platform support

Platform IPC mechanism
Linux Unix domain sockets
macOS Unix domain sockets
Windows Named pipes

Platform-specific implementations are selected at compile time via #[cfg].

Project structure

src/
β”œβ”€β”€ main.rs
β”œβ”€β”€ switch/         # IPC server β€” accepts RPC client connections
β”‚   └── ipc/
β”‚       β”œβ”€β”€ mod.rs      # Server and Client logic
β”‚       β”œβ”€β”€ unix.rs     # Unix domain socket listener
β”‚       └── windows.rs  # Named pipe listener
└── discord/        # IPC client β€” connects to real Discord instances
    β”œβ”€β”€ api.rs          # Discord REST API for app metadata (cached)
    └── ipc/
        β”œβ”€β”€ mod.rs      # Client, protocol types, socket discovery
        β”œβ”€β”€ unix.rs     # Unix domain socket connection
        └── windows.rs  # Named pipe connection

About

πŸ€– One Discord IPC to many, for multi-Discording

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages