Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda