This PR introduces the server-side logic to support real-time peer-to-peer video chat using Socket.io and WebRTC signaling. The backend acts as a signaling server to manage user connections, room creation, offer/answer exchanges, and ICE candidates. Below is a breakdown of the changes introduced.
Changes Made
index.js – Server entry point:
Sets up Express and Socket.io for the backend.
Manages client connections and disconnections.
Initializes the UserManager to handle active users.
Listens for WebRTC signaling events (offer, answer, add-ice-candidate).
RoomManager.js – Manages WebRTC rooms:
Creates rooms dynamically when two users are available.
Stores room details, including connected users.
Facilitates offer and answer exchanges between peers.
Manages ICE candidate forwarding between participants.
UserManager.js – Handles user sessions and queuing:
Tracks connected users and manages user queues.
Automatically pairs users when two are available.
Provides methods to add or remove users on connection events.
Initializes WebRTC signaling handlers for each user.
How to Test This PR
Setup:
Run npm install to install dependencies.
Start the server with node src/index.js.
Open two browser windows/tabs:
Connect from both windows to trigger room creation.
Verify that offers, answers, and ICE candidates are exchanged correctly through the server.
Expected Logs:
"User connected: "
"Offer sent from to "
"Answer sent from to "
"ICE candidate sent from to "
Known Issues / Improvements
Room cleanup on disconnection can be improved to handle edge cases.
Adding error handling for failed WebRTC connections.
Implement session management to persist user data across reconnects (future enhancement).
Description
This PR introduces the server-side logic to support real-time peer-to-peer video chat using Socket.io and WebRTC signaling. The backend acts as a signaling server to manage user connections, room creation, offer/answer exchanges, and ICE candidates. Below is a breakdown of the changes introduced.
Changes Made
index.js
– Server entry point:UserManager
to handle active users.RoomManager.js
– Manages WebRTC rooms:UserManager.js
– Handles user sessions and queuing:How to Test This PR
npm install
to install dependencies.node src/index.js
.Expected Logs:
Known Issues / Improvements