This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
jDRPC is a Java 17+ library for Discord Rich Presence via the Discord IPC protocol. Package: fun.crashsystem.jdrpc.
./gradlew build # Compile and package
./gradlew javadoc # Generate JavadocNo tests exist yet. The build uses java-library plugin with Java 17 toolchain. Lombok is compile-only (annotation processing).
Layered, event-driven design with a single facade entry point:
DiscordIPC- Main facade. Thread-safe, implements Closeable. All public API goes through here.DiscordIPCConfig- Immutable config record with builder pattern.
ConnectionManager- Lifecycle management, auto-reconnect with exponential backoff (1s-60s)ConnectionState- Sealed interface state machine: Disconnected -> Connecting -> Connected -> Reconnecting -> Failed/ClosedConnectioninterface with platform implementations:UnixConnection(Java 17 Unix domain sockets) andWindowsConnection(named pipes via RandomAccessFile)PipeLocator/PipePathProvider- Discovers Discord IPC pipes 0-9 across builds (STABLE/PTB/CANARY)
Wire format: [OpCode:4B LE][Length:4B LE][JSON UTF-8]. OpCodes: HANDSHAKE(0), FRAME(1), CLOSE(2), PING(3), PONG(4). Max frame size 64KB.
CommandExecutor uses nonce-based request/response correlation with CompletableFuture. Optional token-bucket rate limiting. Default 10s timeout.
EventDispatcher routes frames to DiscordEventListener callbacks (CopyOnWriteArrayList). Default empty implementations so consumers override only what they need.
activity/- Activity record with builder, ActivityType enum, assets, buttons, party, timestamps, secretsentity/- User record, DiscordBuild enumerror/- Exception hierarchy:DiscordIPCException->ConnectionException,CommandException,NoDiscordClientException.RpcErrorCodeenum.
Two daemon threads: jDRPC-worker (I/O read loop, responds to Discord PINGs with PONGs), jDRPC-async (async API calls). Thread safety via AtomicReference, ReentrantLock on writes, ConcurrentHashMap for pending commands.
- Gson 2.11.0 - All JSON serialization (API scope)
- SLF4J 2.0.13 - Logging facade, no impl bundled (API scope)
- Commons Lang3 3.14.0 - StringUtils, ObjectUtils (API scope)
- Lombok 1.18.36 - @Getter, @Slf4j, @Builder, @NonNull (compile-only)