D
D
Darklarens2020-10-20 19:30:29
JavaScript
Darklarens, 2020-10-20 19:30:29

Where can I find examples of how Socket.io and Express work?

Hello, where can I see examples of

how Socket.io and Express work for different

tasks ? kabinet.ejs", setSite) }), from express I can't put io.on connect into it, because the problem of "Accumulation of connections" appears. If I take out io.on separately, then how to process functions inside io.on ? Example: io.on('connection', function(socket){ console.log('User connected'); sendUser(1,socket); }); async function sendUser(s,socket){ var mm = await data.getUser(s)


socket.emit('sendToClient', { name: mm['name'], inrt: mm['rate'] });
}
In this example, there is a problem "TypeError: Cannot read property 'emit' of undefined"

In general, how they work together
I do not understand
Please help
Who is not lazy, here is the Darklarens#5695 discord
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zhanna_K, 2020-10-20
@Zhanna_K

I saw a cool tutorial on the TraversyMedia channel, the described stack is just used)
Search on youtube

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question