Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:10:10+00:00 2026-06-11T04:10:10+00:00

I am working on a game in Construct2 at the moment. It is a

  • 0

I am working on a game in Construct2 at the moment.
It is a HTML5 Javascript Engine.
I probably implement clay.io inside it.

My question however is about “Rooms”
Clay.io also helps with Rooms. However I am not sure If I will take that offer.
https://clay.io/docs/rooms

So when I want to limit the users per game to 10 for example. Would I then need to run two servers?

The socket.io server recives and returns data.. But would two games running with each 10 people not confuse the servers data? When person A on server A shoots some1, that this information could somehow end up on Person B on server B?
Or do the assigned ID’s prevent this somehow?

Here is the Example Server that I want to upgrade for my needs:

   var entities = [], count = 0;
    var io = require("socket.io").listen(8099);

    var INITIAL_X = 5;
    var INITIAL_Y = 5;
    var INITIAL_VEL_X = 0;
    var INITIAL_VEL_Y = 0;

    io.set('log level', 1);
    io.sockets.on("connection", function (socket) {
        var myNumber = count++;
        //assign number    
        var mySelf = entities[myNumber] = [myNumber, INITIAL_X, INITIAL_Y, INITIAL_VEL_X, INITIAL_VEL_Y];

        //Send the initial position and ID to connecting player
    console.log(myNumber + ' sent: ' + 'I,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2]);
        socket.send('I,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2]);
        //Send to conencting client the current state of all the other players
        for (var entity_idx = 0; entity_idx < entities.length; entity_idx++) { 
//send initial update  
            if (entity_idx != myNumber) {
                entity = entities[entity_idx];
                if (typeof (entity) != "undefined" && entity != null) {

                console.log(myNumber + ' sent: C for ' + entity_idx);
                socket.send('C,' + entity[0] + ',' + entity[1] + ',' + entity[2]); 
//send the client that just connected the position of all the other clients 
            }
        }
    }
    //create new entity in all clients    
    socket.broadcast.emit("message",
        'C,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2]);
    socket.on("message", function (data) {

        //if (myNumber == 0)
        //    console.log(myNumber + ' sent: ' +data);
        var new_data = data.split(',');
        if (new_data[0] == 'UM') {
            mySelf[1] = new_data[1];
            mySelf[2] = new_data[2];
            mySelf[3] = new_data[3];
            mySelf[4] = new_data[4];
            //Update all the other clients about my update
            socket.broadcast.emit("message",
            'UM,' + mySelf[0] + ',' + mySelf[1] + ',' + mySelf[2] + ',' + mySelf[3] + ',' + mySelf[4]);
        }
        else if (new_data[0] == 'S') { // a s message
            var shoot_info = [];
            shoot_info[0] = new_data[1]; //ini x
            shoot_info[1] = new_data[2]; //ini y

            shoot_info[2] = new_data[3]; //degrees

            //Update all the other clients about my update
            socket.broadcast.emit("message",
            'S,' + mySelf[0] + ',' + shoot_info[0] + ',' + shoot_info[1] + ',' + shoot_info[2]);
        }
    });

});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:10:11+00:00Added an answer on June 11, 2026 at 4:10 am

    Socket.io has rooms that you can limit the broadcasts to, see: https://github.com/LearnBoost/socket.io/wiki/Rooms

    Then rather than use socket.broadcast.emit you would use io.sockets.in('roomname').emit

    A good way to mesh this with Clay.io is to have the room name be the room.id (in the Construct 2 plugin that’s the RoomId expression). When the Clay.io room fills up (in C2 there’s a condition for that), create the Socket.io room using that unique ID and put the players who “Rooms Filled” was just called for in that room.

    I know it’s a bit different since it’s a game written in CoffeeScript instead of Construct 2, but we’re using Clay.io rooms + Socket.io rooms in our Slime Volley game. Here is the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yo everyone! I have been working on an Isometric Tile Game Engine in HTML5/Canvas
I'm working on a game engine in C++ and I have methods like setColour
I'm creating a DSL for an extensible card game engine I'm working on, with
I had my game working and then decided to try and implement a menu
I'm currently working on a custom UI engine for a game. I've very basic
I'm working on a game engine and working on implementing a state design. I
This question is intended for someone who is in game development, possibly working in
I'm working on a game with a bunch of mini games. Inside one gameview,
I have been working a platforming game for about three months. I had the
I'm trying to make a fully-automated game engine which needs to be working based

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.