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

  • 0
    Hello, where can I see examples of how Socket.io and Express work for different tasks.

    I can’t solve the problem, I can solve the problem with an example.

    There is
    app.get ("/ kabinet", function (request, response) {
    response.render ("kabinet.ejs", setSite)
    }), from express

    I can't put io.on connect into it, because the problem "Connections accumulation" appears.
    If I take out io.on separately, then how to handle 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 such example there is a problem "TypeError: Cannot read property 'emit' of undefined"

    In general, how should they work together?
    I won't understand.
    I ask for help
    Darklarens Discord # 5695
    Thank you!
    JavaScript Wyatt Liu, Oct 21, 2019

  • 1 Answers
  • 0
    I saw a cool tutorial on TraversyMedia's channel, the described stack is just used)

    Search on youtube
    Hazel Hatfield

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!