Answers for "keeping socket.io between pages"

1

keeping socket.io between pages

there is no official method to this,
but,
you fake this with iframes in one page that holds  a socket and passes it 
to the iframes when they load.

Main page js:

var socket = io();
iframe.onload = function(){
	iframe.contentWindow.setSocket(socket);
}

On the pages in the iframe:

var socket;
function setSocket(sock){
	socket = sock;
    //add listeners and emitters etc socket.on()
}
Posted by: Guest on September-07-2021

Browse Popular Code Answers by Language