Note that there are some explanatory texts on larger screens.

plurals
  1. POSocket.io several rooms in Construct2
    primarykey
    data
    text
    <p>I am working on a game in Construct2 at the moment. It is a HTML5 Javascript Engine. I probably implement clay.io inside it.</p> <p>My question however is about "Rooms" Clay.io also helps with Rooms. However I am not sure If I will take that offer. <a href="https://clay.io/docs/rooms" rel="nofollow">https://clay.io/docs/rooms</a></p> <p>So when I want to limit the users per game to 10 for example. Would I then need to run two servers?</p> <p>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?</p> <p>Here is the Example Server that I want to upgrade for my needs:</p> <pre><code> 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 &lt; entities.length; entity_idx++) { //send initial update if (entity_idx != myNumber) { entity = entities[entity_idx]; if (typeof (entity) != "undefined" &amp;&amp; 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]); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload