New Network / Stream Room System

Get the latest news on new features, bug fixes and version updates right here!

New Network / Stream Room System

Postby rob » Sun Dec 01, 2013 3:51 pm

There have been a lot of questions about how to implement rooms in IGE so I decided to write a new extension to the stream system to allow you to create and assign clients to rooms VERY easily.

The basics are:

* The system is switched off by default so it will not affect existing games / code
* Rooms are defined by a root scene entity so a scene effectively "becomes" a room as well
* Clients are only sent data updates about entities that are mounted to a room that they have been assigned to
* Clients can be assigned to multiple rooms at a time (think multi-room poker etc)

To define a scene as a room root, call the IgeScene2d method streamRoomId:

Code: Select all
var room = new IgeScene2d()
    .streamRoomId('room1');


For convenience, you can auto-stream all entities mounted to this scene by setting the streamMode and then calling compositeStream(true):

Code: Select all
room
    .streamMode(1)
    .compositeStream(true);


By setting the stream room id on the scene, no clients will recieve ANY entity data by default. You then have to add a client to the room after which the stream system will start streaming updates for that room to the client (on the server-side, maybe in Server.js):

Code: Select all
// Define a network command the client can use to request to join a room by a room id
ige.network.define('joinRoom', clientWantsToJoinRoom);

function clientWantsToJoinRoom (data, clientId, requestId) {
    ige.network.clientJoinRoom(clientId, data.roomId);
    ige.network.response(requestId, {success: true});
}


Then on the client you can request a room join via:

Code: Select all
function joinRoom (roomId) {
    ige.network.request('joinRoom', {roomId: roomId}, function (cmd, result) {
        if (result.success) {
            // Success! - Here you might want to destroy any lobby UI you might have had
        }
    });
}


Now you can join any room on the server from the client via a single request:

Code: Select all
ige.client.joinRoom('room1');
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: New Network / Stream Room System

Postby dnasello » Tue Dec 03, 2013 1:02 pm

awesome.
dnasello
 
Posts: 41
Joined: Wed Oct 23, 2013 9:44 pm

Re: New Network / Stream Room System

Postby lucbr » Wed Dec 04, 2013 3:11 am

Thanks a lot! I really need it!
lucbr
 
Posts: 27
Joined: Fri Oct 25, 2013 3:26 am

Re: New Network / Stream Room System

Postby ericle » Mon Dec 09, 2013 9:25 am

This looks great! However, being quite new to what's available in the engine and optimal usecases for different features, I have a question.

What's the fundamental difference between these rooms and say for example a map in an RPG game? It seems to me that this could be used in both
scenarios, but I realize this feature is described more from a lobby/room point of view.
ericle
 
Posts: 2
Joined: Wed Oct 23, 2013 7:58 pm

Re: New Network / Stream Room System

Postby rob » Mon Dec 09, 2013 9:31 am

ericle wrote:This looks great! However, being quite new to what's available in the engine and optimal usecases for different features, I have a question.

What's the fundamental difference between these rooms and say for example a map in an RPG game? It seems to me that this could be used in both
scenarios, but I realize this feature is described more from a lobby/room point of view.

You are correct, the system is designed to work for both scenarios but primarily for sectioning off the multiplayer traffic for each room of an rpg game.

It can also be used to make separate rooms in a poker game or as you suggested a lobby. Anywhere that your game would benefit from automatically restricting steam updates to different groups of players.

Cheers!
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: New Network / Stream Room System

Postby ericle » Mon Dec 09, 2013 11:43 am

rob wrote:You are correct, the system is designed to work for both scenarios but primarily for sectioning off the multiplayer traffic for each room of an rpg game.

It can also be used to make separate rooms in a poker game or as you suggested a lobby. Anywhere that your game would benefit from automatically restricting steam updates to different groups of players.

Cheers!

Perfect! Thanks for the clarification. And great job on all the updates and new features.
ericle
 
Posts: 2
Joined: Wed Oct 23, 2013 7:58 pm

Re: New Network / Stream Room System

Postby robaldred » Mon Dec 09, 2013 12:39 pm

Great work Rob, you've been very busy, new features look excellent!
I don't work for Irrelon. All comments are my own.
I would strongly encourage anyone building production projects with Isogenic to buy a premium licence, it costs very little and will help towards continued development of the engine. Irrelon have spent thousands of hours developing this wonderful platform with many features found in AAA game engine.
User avatar
robaldred
 
Posts: 243
Joined: Wed Oct 23, 2013 8:09 pm
Location: Manchester, England

Re: New Network / Stream Room System

Postby rob » Tue Dec 10, 2013 9:54 pm

robaldred wrote:Great work Rob, you've been very busy, new features look excellent!


:) thanks everyone for the nice feedback.
CEO & Lead Developer
Irrelon Software Limited
http://www.isogenicengine.com
User avatar
rob
Site Admin
 
Posts: 316
Joined: Tue Oct 22, 2013 5:08 pm

Re: New Network / Stream Room System

Postby Solib » Wed Dec 11, 2013 1:31 am

Hi Rob.
I recently started studying nodeys
And yet not quite understand many things today are severely lacking me an example of how it works streamroomid. If you have time you can look at my source and point out my mistakes.

https://github.com/Solib/exemple-stream-romId

The script should work. The first user gets in room1, second flagged room2, third in room1, the fourth in room2 and other in room1.
I already did download maps, they only difference is in one cell but it is enough to see what room turned user.

If you do not want to understand what I wrote, it would be great to see an example of your hands. (Some things I know when I see how they work)

Thank you for your attention :)
Solib
 
Posts: 17
Joined: Thu Oct 24, 2013 4:27 am

Re: New Network / Stream Room System

Postby Solib » Tue Dec 17, 2013 4:38 am

Good day!
Now I do not understand how to create initiate stream.
client.js
Code: Select all
// Setup the network stream handler
                  ige.network.addComponent(IgeStreamComponent)
                     .stream.renderLatency(80) // Render the simulation 160 milliseconds in the past
                     // Create a listener that will fire whenever an entity
                     // is created because of the incoming stream data
                     .stream.on('entityCreated', function (entity) {
                        self.log('Stream entity created with ID: ' + entity.id());
                     });

"entityCreated" not called
how can I create a new stream in a different way?
Solib
 
Posts: 17
Joined: Thu Oct 24, 2013 4:27 am

Next

Return to New Features, Latest Versions & General Updates

Who is online

Users browsing this forum: No registered users and 0 guests