Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
real-time-tv
Advanced tools
Readme
built with Create React App redux and socket.io.
Real-Time TV then open another tab to the same url and paste a youtube url in and watch the rtc magic happen.
npm i --save real-time-tv
Unfortunately The Component was ejected as such, to enable the css it has to be used with an ejected app using css modules plugin.
or clone the git repo and run in dev server port is set to 5000.
npm install
npm start
`newVideo` event
`isReady` event
`stateChange` event
`placeChange` event
here is the example server responding to the events
io.on("connection", socket => {
const userId = socket.id;
connIds.push(userId);
// newVideo event
socket.on("newVideo", vidObj => {
const objSend = {
url: vidObj.url,
id: vidObj.vidId,
screenState: vidObj.screenState,
controlId: vidObj.controlId
};
io.emit("updateVideo", objSend);
});
// isReady when all are ready emit allIsReady
socket.on("isReady", socketId => {
clientIds.push(socketId.ids);
let objSend = {
msg: null
};
const clients = Object.keys(io.sockets.sockets);
promisePoller({
taskFn: () => {
return new Promise((resolve, reject) => {
if (clients.length === clientIds.length) {
resolve(true);
} else {
reject(`${clients.length - clientIds.length}`);
}
});
},
interval: 500,
retries: 5,
})
.then(poll => {
if (poll === true) {
io.emit("allIsReady");
}
}).catch(err => {
objSend.msg = `${err[err.length]} user(s) not connected.`;
io.emit("allIsReady", objSend);
});
});
// stateChange event
socket.on("stateChange", stateObj => {
const objSend = {
state: stateObj.state
};
socket.broadcast.emit("updateState", objSend);
});
// placeChange event
socket.on("placeChange", placeObj => {
const objSend = {
place: placeObj.ytPlace
};
io.emit("updatePlace", objSend);
});
socket.on("disconnect", () => {
console.log(`user disconnected`);
const id = socket.id;
const newConnIdArr = filterIds(connIds, id);
const newClientIdArr = filterIds(clientIds, id);
connIds = newConnIdArr;
clientIds = newClientIdArr;
});
});
FAQs
Real-time video player component built with react and socket.io
The npm package real-time-tv receives a total of 0 weekly downloads. As such, real-time-tv popularity was classified as not popular.
We found that real-time-tv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.