Skip to content

Create App.js(client)updated code #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Junaid2003
Copy link

Updated the code with react router v6

Updated the code with react router v6
@Junaid2003
Copy link
Author

//updated server.js file to latest so that it can work in 2023 hope you can accept pull request. I was not able to commit server.js file so i have pasted the code below.
const express = require("express");
const http = require("http");
const app = express();
const server = http.createServer(app);
const socket = require("socket.io");
const io = socket(server);

const rooms = {};

io.on("connection", socket => {
socket.on("join room", roomID => {
if (rooms[roomID]) {
rooms[roomID].push(socket.id);
} else {
rooms[roomID] = [socket.id];
}
const otherUser = rooms[roomID].find(id => id !== socket.id);
if (otherUser) {
socket.emit("other user", otherUser);
socket.to(otherUser).emit("user joined", socket.id);
}
});

socket.on("offer", payload => {
    io.to(payload.target).emit("offer", payload);
});

socket.on("answer", payload => {
    io.to(payload.target).emit("answer", payload);
});

socket.on("ice-candidate", incoming => {
    io.to(incoming.target).emit("ice-candidate", incoming.candidate);
});

});

server.listen(8000, () => console.log('server is running on port 8000'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant