Both Tictactoe and Chatapp use socket io in Nodejs. I want to combine Tictactoe game and Chatapp in one means while playing tictactoe game user can chat in chatapp which is embedded in tictactoe game webpage by iframe ( embedded chatapp webpage in tictactoe webpage ). So I combined both the server files in one server file .
app.get("/chat-box", function (req, res) {
res.sendFile(__dirname + "/static/HTML/chat-box.html");
});
app.get("/tic-tac-toe", function (req, res) {
res.sendFile(__dirname + "/static/HTML/tic-tac-toe.html");
});
I tried by both the methods . 1) First method is to write both codes in single io.on.connection
io.on("connection", function (socket) {
...
Tictactoe code
Chatapp code
}
io.on("connection", function (socket) {
...
Tictactoe code
}
io.on("connection", function (socket) {
...
Chat app code
}
But the problem is that as chatapp is embedded in game by iframe tag so problems is that tictactoe user gets connected twice so that user doesn't get connected with another player and so game doesn't work but chatapp works.