P2P Video Chat App: Cannot figure out how to use socket.io-stream

I am trying to make a real time P2P video chat application.

I found out that using socket.io-stream library would help.
But I cannot figure out how to implement this library.

My video player is working fine at client side though. I just want to transfer this stream to other connected clients using socket.io.

My server code is given below

let app = require("express")();
let ss = require("socket.io-stream");
let http = require("http").createServer(app);
const routes = require("./routes");
let io = require("socket.io")(http);
routes(app, __dirname);
http.listen(3000, () => {
    console.log("app listening on port ", 3000);

io.sockets.on("connection", (socket) => {
    socket.on("joinRoom", (obj) => {
        let { name, stream } = obj;
        console.log(name, stream);

and my client side script is given below

<!DOCTYPE html>
<html lang="en">

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Video Calling</title>

    <video autoplay="true" id="video"></video>
    <script src="/socket.io/socket.io.js"></script>
        const socket = io();
        let name = prompt("Enter the room name");

        function wrongname() {
            name = prompt("Seriously? That's not a name! enter again!");

        function validator() {
            if (!name.match(/^[0-9a-z]+$/)) {
            } else {
                return true;
        let video = document.getElementById('video');
        if (navigator.mediaDevices.getUserMedia) {
                    video: true,
                    audio: true
                .then((stream) => {
                    video.srcObject = stream;
                    socket.emit("joinRoom", {
                        name: name,
                        stream: stream
                .catch((error) => {
                    alert("You choose to turn off your video and audio");


I repeat, my problem is to stream video through socket.io using socket.io-stream(if there is any other alternative it is fine)

My code with GitHub link up to this point is here

I hope my query is easy to understand.