kaali001 / varta

A online video chat platform which matches two people who are learning same languages.
https://varta-online.vercel.app
5 stars 6 forks source link

feat: Added Server-Side Logic for WebRTC Video Chat Application #2

Closed kaali001 closed 1 week ago

kaali001 commented 1 week ago

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

  1. 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).
  2. 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.
  3. 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

  1. Setup:
  1. Open two browser windows/tabs:
  1. Expected Logs:

    "User connected: " "Offer sent from to " "Answer sent from to " "ICE candidate sent from to "

Known Issues / Improvements