Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
how to combine two socket io apps in one server ? ( Tictactoe game and Chatapp)

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
}
  1. Second method is to write separate io.on.connection codes for both

    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.

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda