What I'm trying to do is integrate my HTML5 canvas games into a single web interface.
When the button is pressed, the html game fills up <div id="game">. But I've only defined my node.js in my javascript file.
Now I can probably define it also in the HTML2 file, but it seems it will create 2 seperate connections.
Is there a way of doing this while having only 1 connection?
Simply put - 2 seperate HTML/javascript files with same exact connection
Thank you
HTML
<div id="game">
<button id="gameFile">MyGame</button>
</div>
Javascript
var socket = io('http://192.168.0.5:2000');
socket.on('connect', function() {
socket.emit('login', {
});
});
$('#gameFile').click(function(event){
document.getElementById("game").innerHTML='<object type="text/html" data="games/myGame/index.html" style="width:100%; height: 100%;" ></object>';
});
HTML2 (games/myGame/index.html)
<canvas id="myCanvas">
Your browser does not support the HTML5 canvas tag :(
</canvas>
<script>
socket.emit('msg', "2nd HTML connected");
</script>
sessionIdto determine and join the same room? like,socket.on('connection', function (socket) {socket.join(socket.handshake.sessionID);});?<div id="game">tag