Skip to content Skip to sidebar Skip to footer

How Can I Let The Javascript Catch A Signal From Node And Prompt A Window Right After That?

I want to emit a signal from the app.js. The ejs file should catch it and prompt a window. The problem is I have to refresh the page to see the window. Also it seems it will be alw

Solution 1:

io.sockets.on('connection', function (socket) {
    io.sockets.emit('example_signal')
})

it will somehow wait for the page refresh...

Because that is what that code says:

When the browser connects to the socket, emit a signal

… and the browser will connect to the socket when the page loads.

Removing the event handler that waits for a new connection will, naturally, cause the line io.sockets.emit('example_signal') to run immediately instead of waiting for the event.


Post a Comment for "How Can I Let The Javascript Catch A Signal From Node And Prompt A Window Right After That?"