undefined user and room methods?

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

undefined user and room methods?

Postby Poyz » 20 Apr 2006, 13:27

Hello everyone
got a problem with user and room methods:
i made an swf that connects and logs in, but when i try the chat part:

smartfox.onPublicMessage = function(msg:String, sender:User) {
trace (sender.getName());
trace (sender.getId());
chat_txt.text += msg;
}
smartfox.onJoinRoom = function(roomObj:Room)
{
trace("Successfully joined room: " + roomObj.getName())
}

the msg makes it and appears correctly on the textfield, while in the trace window i get:

Successfully joined room: Undefined
Undefined
Undefined

anybody knows what could be the problem??
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Apr 2006, 10:29

A joinRoom event that returns an undefined can only mean that you don't have the room list available on your side.

Do you handle the onRoomListUpdate() ?

Maybe are you using a custom login on the server side?
Lapo
--
gotoAndPlay()
...addicted to flash games
Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

Postby Poyz » 21 Apr 2006, 10:42

yes i'm using custom login and i have an onRoomListUpdate handler

this is what i get in the trace window:

[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='102' /></body></msg>

[Received]: <cross-domain-policy><allow-access-from domain="*" to-ports="9339" /></cross-domain-policy>
[Received]: <msg t="sys"><body action="apiOK" r="0" /></msg>
[Sending]: <msg t='sys'><body action='login' r='0'><login z='test'><nick><![CDATA[pois]]></nick><pword><![CDATA[xxyyzz]]></pword></login></body></msg>

[Received]: <msg t="xt"><body action="xtRes" r="-1">&lt;dataObj&gt;&lt;var n=&apos;_cmd&apos; t=&apos;s&apos;&gt;LogOK&lt;/var&gt;&lt;/dataObj&gt;</body></msg>
[Sending]: <msg t='sys'><body action='getRmList' r='-1'></body></msg>

roomlist requested
[Received]: <msg t="sys"><body action="joinOK" r="1"><pid id="0" /><vars /><userList r="1"><user id="0" name="Pois" mod="0"><vars /></user></userList></body></msg>
[Received]: <msg t="sys"><body action="rmList" r="0"><rmList><rm id="1" priv="0" temp="0" game="0" ucnt="1" maxu="100" maxs="0"><n>intro</n></rm></rmList></body></msg>
onRoomListUpdate fired
[Sending]: <msg t='sys'><body action='pubMsg' r='1'><txt><![CDATA[test message]]></txt></body></msg>

[Received]: <msg t="sys"><body action="pubMsg" r="1"><user id="0" /><txt>test message</txt></body></msg>
undefined
undefined

the last 2 undefined are
trace (sender.getName());
trace (sender.getId());

i really dont understand what i'm doing wrong :(
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 21 Apr 2006, 10:47

you're not waiting the room list :)

See in your debug code: the joinOK arrives before the roomListUpdate
This means that the client APIs don't have the room info available at the time the join is successfull.

Just wait the onRoomListUpdate() event before sending the join request

:)
Lapo

--

gotoAndPlay()

...addicted to flash games
Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

Postby Poyz » 21 Apr 2006, 11:22

thanks :)
i'm trying to fix this... but i found another problem to solve before i can check if everything is ok ^^
opening another thread heh :)
Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

Postby Poyz » 21 Apr 2006, 12:02

ok works thanks lapo
Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

Postby Poyz » 21 Apr 2006, 13:45

Looks like this roomListUpdate is necessary to init the API.
It sends all the zone info about rooms right?
But i was wondering: what if there are some rooms i dont want the client to know about? for example game rooms or some chatrooms
This also makes me think that not only onRoomListUpdate() is necessary for the API to work correctly and not return undefined values, but also onRoomAdded(), and what if i dont want users to know if and when a new room is created?
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 Apr 2006, 15:07

You can hide rooms by using the so called "Limbo Rooms"
We used them in our "SmartMessenger" example available with SFS 1.4.0

Check this document for further info
Lapo

--

gotoAndPlay()

...addicted to flash games
Poyz
Posts: 83
Joined: 28 Mar 2006, 14:27

Postby Poyz » 22 Apr 2006, 16:38

limbo rooms look cool :)
but they dont send user info, is there a way to create a "normal" room that just isn't listed in the roomlistupdate
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 24 Apr 2006, 17:38

You could send your own version of the roomListUpdate() event.
This can be done with the sendGenericMessage() on the server side (see docs)

What you have to do is study the XML format of the event and reproduce it, passing only the data you want.

Here's an example:

- Client sends login
- Server checks credentials and if it's ok sends a "logOk" response
- Server prepares a "fake" onRoomListUpdate event by sending the xml with the room data
- Client handles the event transparently

This way you can "hide" any room, not just the "limbo" ones...
NOTE: you can also disable the events that are fired when a new room is added.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 35 guests