Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

228
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!