Forum C# Room Data?

Room Data?

Postby playstation3Dood » March 4th, 2010, 1:47 am

hi guys, how does roomData work? I've looked through the documentation, but i dont get it lol :D ...
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby Benjaminsen » March 4th, 2010, 12:35 pm

When you create a room you can parse data from the client to the server.

Think of this as initialization data for the room.
The data is send as an object. IE {level:3, time:15000} and is accessible on the server as a key value pair. See
http://playerio.com/documentation/refer ... y.roomdata

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Room Data?

Postby playstation3Dood » March 4th, 2010, 12:38 pm

Hi thanks for the reply, but how do you get the data for a particular room? that's the part i didn't understand. The example given contains
Code: Select all
var somevariable = RoomData["myvarname"];

but how do I know which room it is getting the data from?
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby Benjaminsen » March 4th, 2010, 1:09 pm

From the server the room data is only accessible from the room the data was created with.
IE a room is created when you call createJoinRoom or createRoom

You can also access the room data from a listRooms on the client. Here the data is tied to the current RoomInfo object.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Room Data?

Postby playstation3Dood » March 4th, 2010, 2:00 pm

Ok so say i had to get a the variable from all rooms, say the current map or the creator of the room etc., from the server side. is that possible?

btw can room data be modified clientside?
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby Benjaminsen » March 4th, 2010, 2:05 pm

As of now you cannot request data that is not tied to the current room. You will have to wait for the data API for this.

You are not able to edit room data from the client after creation of the room.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Room Data?

Postby playstation3Dood » March 4th, 2010, 2:31 pm

Thank you Chris/Benjamin --whichever :D so there is no way to say make a list of all rooms marked with the map being played in each room?
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby Benjaminsen » March 4th, 2010, 2:39 pm

It's quite possible from the client. Using listRooms

See
http://playerio.com/documentation/refer ... minfo#data
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Room Data?

Postby playstation3Dood » March 5th, 2010, 1:49 am

Ok so it has to be done from the client side, cant be done from the serverside. got it. Thanks

Oh and on a side note, is there something like a roomCreated() function on the server? something that will be called each time a room is created.
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby Oliver » March 5th, 2010, 3:08 pm

RoomData
Room data is sent to the room when the room is created by the client. RoomData can only be modfied in the owning room on the serverside. Listrooms returns the roomdata for the rooms returned in the list.


Oh and on a side note, is there something like a roomCreated() function on the server? something that will be called each time a room is created.

You have a GameStarted() function that's called on each room when it's created.
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Room Data?

Postby playstation3Dood » March 6th, 2010, 12:28 am

Ok thanks for clearing everything up Oliver. I think i know how to preceed now.
playstation3Dood
 
Posts: 49
Joined: February 23rd, 2010, 7:39 am

Re: Room Data?

Postby General » April 29th, 2013, 8:50 am

I have a question about the roomdata, too.
I added custom data parameter named phase to let the klient know is the game already running or it it still gathering the players.

When creating the game phase must be 1, and as the actual game starts, it must be 2.

In client I write:
Code: Select all
         _client.multiplayer.createRoom(
            null,                        //Room id, null for auto generted
            _roomType,                     //RoomType to create, bounce is a simple bounce server
            true,   //Hide room from userlist
            {name:e.stringVal, victoryRule:wr, blockRule:br, phase:1},   //Room Join data, data is returned to lobby list. Variabels can be modifed on the server
            joinRoom,                     //Create handler
            _handleJoinError               //Error handler                                 
         )


The phase really equals to 1, as I can check it on the server by running this code:
Code: Select all
            // looping over all room data
            foreach(var kv in RoomData) {
                Console.WriteLine("RoomData[" + kv.Key + "] = " + kv.Value );
            }


After all is ready to start the game at the server I call
Code: Select all
this.RoomData["phase"] = "2";


I also verify on the serverside by tracing into console that phase is really 2, not 1.

But after starting a game in 2 swf files, I run the third swf file and try to list rooms.
I use this code:
Code: Select all
_client.multiplayer.listRooms(_roomType, {phase:1}, 8, 0, onListComplete, onListError);


And in onListComplete I trace the room info
Code: Select all
      var rinf:RoomInfo;
         
         for each (rinf in rooms) {
            trace('room found');
            trace(rinf.id);
            trace(rinf.data.phase);
            trace(rinf.onlineUsers);
         }

And I get that the phase's value is 1, not 2. While the Server showd me that the room's phase is 2.

Have you encountered the situation like this? Please, help me.

Also, on Multiplayer Rooms settings I've got "Search Column 1:" named phase
General
 
Posts: 4
Joined: April 15th, 2012, 12:56 pm

Re: Room Data?

Postby RastaRalle » April 29th, 2013, 7:17 pm

did you call save() on the roomdata?
RastaRalle
 
Posts: 63
Joined: August 18th, 2010, 2:46 pm

Re: Room Data?

Postby General » April 29th, 2013, 8:09 pm

Completely missed this :)
Thank you very much, now everything works!
General
 
Posts: 4
Joined: April 15th, 2012, 12:56 pm


Return to C#



cron