Create room and room variables not coming i
Create room and room variables not coming i
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?
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
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
Re: Create room and room variables not coming i
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.
Ok for the error in Carl's code... (I didn't see it)
This is my code:
this don't work
Thank's[/code]
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]
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>
Thanks Patso
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!
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
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
Melojoy, your variables are not going out?
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....
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.
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
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
This problem has been solved
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.
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
Illustrator, animator, programmer
----------------------------------------
www.gametrust.com
www.chamberofchat.com
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
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
The patch is available. Check this post --> viewtopic.php?t=1060
Return to “SmartFoxServer 1.x Discussions and Help”
Who is online
Users browsing this forum: No registered users and 56 guests