Event Name
join-pr-room
Description
Join a WebSocket room for a specific pull request. Once joined, you’ll receive real-time notifications about messages, typing indicators, and other users in the room.Connection Setup
First, establish a WebSocket connection to the Diffy API:Payload
The ID of the pull request room to join
The username of the user joining the room
Request Example
Server Responses
When a user joins a PR room, the server emits multiple events to all clients in the room:joined Event
Broadcast to all users in the room when someone joins.
Notification message indicating who joinedExample:
"johndoe has joined the chat"user-count Event
Sent to all users in the room with the updated user count.
The total number of users currently in the room
active-users Event
Sent to all users in the room with the list of active usernames.
Array of usernames currently in the room
Listening for Responses
Complete Example
Room Architecture
Diffy uses a room-based architecture where each pull request has its own dedicated room. The room identifier follows the patternpr:{pullRequestId}. Users must join a room before they can send or receive messages specific to that pull request.
Notes
- Users are automatically added to the room upon emitting this event
- The username is stored in the socket’s data and associated with the connection
- All users in the room receive notifications when someone joins
- You must join a room before you can send messages or receive PR-specific updates