Create room and room variables not coming i

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
Carl
Posts: 36
Joined: 22 Dec 2006, 20:40
Location: New York
Contact:

Create room and room variables not coming i

Postby Carl » 27 Dec 2006, 18:51

Hi,

I can't get the room variables to come in right when the user creates a new room. I realize that there is a demo of this in the "advanced chat", but it's becoming clear to me that incorporating the code from the examples into my project is not too straightfoward. It's tempermental to any little change and I'm not sure what I'm doing wrong this time.

Anyway, here is my code for a user generating a room:

function UserCreateRoom() {
var roomObj:Object = new Object();
roomObj.name = ToCreateTitle;
roomObj.password = "";
roomObj.maxUsers = 15;
room.isGame = 1
var variables:Array = new Array();
variables.push({name:"ogres", val:5, priv:false});
room.vars = variables;
smartfox.createRoom(roomObj);
}


And here is my output results. Notice that the outgoing and incoming variables are empty and the isGame state is wrong. Also, it's weird that it's "gam=0" going out, but "game=0" coming back in.


[Sending]: <msg t='sys'><body action='createRoom' r='1'><room upd='0' tmp='1' gam='0' spec='undefined' exit='1'><name><![CDATA[Untitled]]></name><pwd><![CDATA[]]></pwd><max>15</max><vars></vars></room></body></msg>

[Received]: <msg t="sys"><body action="roomAdd" r="0"><rm id="13" priv="0" temp="1" game="0" max="15" spec="0" limbo="0"><name>Untitled</name><vars /></rm></body></msg>


On a side note, I'm wondering a few things...

One is, that I've noticed that the xml in the output window is much easier to read and understand than all these objects. Often I'll see the information in the output xml, but it won't appear from the functions the way I would hope. It also seems like it might be easier to directly edit the xml information rather than trying to use the smartfox functions that I'm having a hard time getting to work right. Is there a way to edit the outgoing xml information directly, and read the incomming xml information directly?

Another question is, why, in the above code, which I got from the manual, do we create an array and then push the items into the array instead of just setting room.vars = the array we want... all in one line? Is there a special way that this would need to be done?
Carl Lydon
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
volcaino
Posts: 1
Joined: 28 Dec 2006, 05:20

Postby volcaino » 28 Dec 2006, 05:24

i'm having the same problem. can someone please post a solution or a link to the solution?

many thanks in advance.
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 04 Jan 2007, 13:04

I have the same problem. I can't get the room variables when I create the room.

thanks :wink:
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Re: Create room and room variables not coming i

Postby patso » 04 Jan 2007, 13:45

Carl wrote:function UserCreateRoom() {
var roomObj:Object = new Object();
roomObj.name = ToCreateTitle;
roomObj.password = "";
roomObj.maxUsers = 15;
room.isGame = 1
var variables:Array = new Array();
variables.push({name:"ogres", val:5, priv:false});
room.vars = variables;
smartfox.createRoom(roomObj);
}

You pass roomObj to the createRoom function. But you add the variables and set isGame to the room object. So there is NO variables and it's not game room beacuse you add these properties to the wrong object. You must add them to roomObj, because you use it as parametar in createRoom function.

Carl wrote:On a side note, I'm wondering a few things...

One is, that I've noticed that the xml in the output window is much easier to read and understand than all these objects. Often I'll see the information in the output xml, but it won't appear from the functions the way I would hope. It also seems like it might be easier to directly edit the xml information rather than trying to use the smartfox functions that I'm having a hard time getting to work right. Is there a way to edit the outgoing xml information directly, and read the incomming xml information directly?


Of course you can read xml information directly if you know how. Something more you can use any language that support sockets(java, c, c++ and much more) to make client. You are not limmeted to flash.
But no offence - I doubt that is easier to parse the incoming xml information than using SFS API functions(btw SFS client side API does exacly this thing - it parses the xml data). On first sight it might look easy, but there are many pitfalls if you are not fammiliar with the SFS protocol and the way server works. And of course it's waste of time to make somethink that is allready made.
Read the tutorial, try to modify some examples and you will se how easy is to use the SFS API.
And be carefull with the spelling of the object and function names.
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 04 Jan 2007, 14:20

Ok for the error in Carl's code... (I didn't see it)

This is my code:

Code: Select all

var gameRoom = new Room()
gameRoom.name = nome
gameRoom.password = pwd
gameRoom.maxUsers = max
gameRoom.isGame = true
gameRoom.isTemp = true

var rVars = new Array()
rVars.push( {name:"gameType", val:gameType} )
rVars.push( {name:"pos", val:tavoloSelezionato} )

gameRoom.variables = rVars

smartfox.createRoom(gameRoom)


this don't work


Thank's[/code]
patso
Posts: 380
Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria

Postby patso » 04 Jan 2007, 14:26

melojoy wrote:Ok for the error in Carl's code... (I didn't see it)

This is my code:

....................................

this don't work


Thank's

Can you give the debug output?
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 04 Jan 2007, 15:24

Code: Select all

[Sending]: <msg t='sys'><body action='createRoom' r='2'><room upd='0' tmp='1' gam='1' spec='undefined' exit='1'><name><![CDATA[Tavolo 4]]></name><pwd><![CDATA[]]></pwd><max>4</max><vars></vars></room></body></msg>

[Received]: <msg t="sys"><body action="roomAdd" r="0"><rm id="43" priv="0" temp="1" game="1" max="4" spec="0"><name>Tavolo 4</name><vars /></rm></body></msg>


:(
User avatar
Carl
Posts: 36
Joined: 22 Dec 2006, 20:40
Location: New York
Contact:

Thanks Patso

Postby Carl » 04 Jan 2007, 15:38

Yea, the good folks at Smartfox spotted my spelling error as well, unfortunately after fixing my variable name, it still doesn't work, the variables go out but they don't come back in. Still working on figuring out what I did wrong; probably something stupid!

I think you're right about the xml. I've done lots of xml reading here at work, and it is quite a job to parse things. I havn't used objects in Flash that much in the past; it; I find it harder to debug because you have to extract the data from them just -so. But it is nice to wrap everything up in a nice package before sending out a game move or something.

I've done allot of work in Director before starting to use Flash, and as an experiment I imported my flash file into Director to see if the multiplayer functionality would still work, and it sure did! I'm not sure if that's the simplest way to use SFP with Director, but at least i know it could work if I need it! I wonder if theres a way for Director to intereact with the server without the intermediate Flash file; I guess someone would have to make an xtra, but seeing as shockwave is not a very big market these days I don't think that woudl be a wise investment for a developer.

So cool!
Carl Lydon

Illustrator, animator, programmer

----------------------------------------

www.gametrust.com

www.chamberofchat.com
User avatar
Carl
Posts: 36
Joined: 22 Dec 2006, 20:40
Location: New York
Contact:

Melojoy, your variables are not going out?

Postby Carl » 04 Jan 2007, 15:46

Melojoy,judging by your output, it looks like your variables are not going out. In my version, they go out, but they just don't come back in.


Check it out, this is the output when the function creates a room and sends my variable called "GameType", between the <vars> brackets we have one variable, it's name, says if it's private, etc. and in [CDATA] we have the actual variable value. I'm not sure if that's what the output is supposed to look like, if it's formatted right, but at least we see the variables....


Code: Select all

[Sending]: <msg t='sys'><body action='createRoom' r='1'><room upd='0' tmp='1' gam='0' spec='undefined' exit='1'><name><![CDATA[Untitled]]></name><pwd><![CDATA[undefined]]></pwd><max>15</max><vars><var n='GameType' t='s' pr='0' pe='0'><![CDATA[8ball]]></var></vars></room></body></msg>



And this is my data coming back in, notice the <var> is empty now, so maybe something is wrong with how I sent it out. Anyway, in your output the variable is missing going out and coming in.

Code: Select all

[Received]: <msg t="sys"><body action="roomAdd" r="0"><rm id="6" priv="1" temp="1" game="0" max="15" spec="0" limbo="0"><name>Untitled</name><vars /></rm></body></msg>
Receiving Room Add
undefined
Carl Lydon

Illustrator, animator, programmer

----------------------------------------

www.gametrust.com

www.chamberofchat.com
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 04 Jan 2007, 16:06

Thank you... but in my output there isn't gameType! :(

I have to create a Room, and immediatly a server extension checks the rooms and sends room's variables to all clients in that zone.

At the moment I send room variables in "onJoinRoom" function...
User avatar
Carl
Posts: 36
Joined: 22 Dec 2006, 20:40
Location: New York
Contact:

This problem has been solved

Postby Carl » 04 Jan 2007, 20:25

This problem has been solved, ask marco about it if he hasn't contacted you already.

Also, "gameType" was just the name of MY variable; yours would be whatever you called it.
Carl Lydon

Illustrator, animator, programmer

----------------------------------------

www.gametrust.com

www.chamberofchat.com
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 05 Jan 2007, 09:54

Marco.... :) please contact me... :?

GameType is also the name of my variable... 8)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 05 Jan 2007, 13:58

Hi,
we tested the issue reported by Carl and we were able to reproduce it. There's a bug during the creation of room variables only when creating a new room. We fixed it and we're now finishing a few tests.

If you are in hurry we can already send you a patch (drop us an email), otherwise I'd recommend to wait a little more as we're going to release the final fix very soon. It's planned for tomorrow.

hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Jan 2007, 17:09

The patch is available. Check this post --> viewtopic.php?t=1060
Lapo

--

gotoAndPlay()

...addicted to flash games
melojoy
Posts: 35
Joined: 02 Oct 2006, 21:27
Location: Italy

Postby melojoy » 08 Jan 2007, 09:05

The patch is also for SmartFoxServer PRO 1.4?
I'm working with this version

Thank you for the update! :)

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 35 guests