This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
PORT #700
Answered
by
abdelhai
nishith-p-shetty
asked this question in
Help
PORT
#700
-
// Node server which will handle socket io connections
const io = require('socket.io')(process.env.PORT || 80, {
cors: {
origin: "*",
methods: ["GET,HEAD,PUT,PATCH,POST,DELETE"]
}
})
console.log(process.env.PORT)
const users = {};
io.on('connection', socket => {
// If any new user joins, let other users connected to the server know!
socket.on('new-user-joined', name => {
users[socket.id] = name;
console.log("Joined", name)
socket.broadcast.emit('user-joined', name);
});
// If someone sends a message, broadcast it to other people
socket.on('send', message => {
socket.broadcast.emit('receive', { message: message, name: users[socket.id] })
});
// If someone leaves the chat, let others know
socket.on('disconnect', message => {
socket.broadcast.emit('left', users[socket.id]);
delete users[socket.id];
});
}) |
Beta Was this translation helpful? Give feedback.
Answered by
abdelhai
Jan 2, 2023
Replies: 1 comment
-
hi, socket.io doesnt work on deta. please search/read the docs. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
abdelhai
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, socket.io doesnt work on deta. please search/read the docs.