sendXTMessage needs roomID?

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

Moderators: Lapo, Bax

Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

sendXTMessage needs roomID?

Postby Sparticus » 02 Mar 2006, 23:14

Things are going much better. I now have the user connecting, joining a room from the server side... but now I am stuck again.

Since I add the user to a room from the server side, there is obviously no "onJoinRoom" method on the client required. So how does the client know what room he is in? does it matter?

I tried to do this command :

Code: Select all

smartfox.sendXtMessage("dbTest", "getuniqueid", obj)


and the server puked this error message :

15:38:43.656 - [ WARNING ] > Extension Call has invalid RoomID. User = Sparticus - /204.209.149.16

invalid roomid? Hmm, is my client supposed to get this from somewhere... and suppose to pass it somehow?

What am I missing.... I'd look at the documentation but I can't find any actual code examples on the new server side functions such as "_server.joinRoom", etc
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Mar 2006, 06:36

Since I add the user to a room from the server side, there is obviously no "onJoinRoom" method on the client required. So how does the client know what room he is in? does it matter?


if you use the joinRoom on the server side you can decide if the onJoinRoom gets fired or not. By default it is.

the syntax is:

Code: Select all

_server.joinRoom(user, currRoomId, leaveRoom, newRoom, pwd, isSpec, sendUpdate)


the last sendUpdate flag is considered as true, if you don't pass it
Are you sure you're calling the method the right way?

invalid roomid? Hmm, is my client supposed to get this from somewhere... and suppose to pass it somehow?

It is likely that you are sending the request without having joined a room. The client can't send any custom request to the server before he has joined at least one room
Lapo
--
gotoAndPlay()
...addicted to flash games
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 03 Mar 2006, 16:11

Hmm... I don't send a message to the server until I joined a room. Below is the code that is run on the server :

Code: Select all

var ok = _server.joinRoom(u,-1,false,1,"",false,false,true)
if (ok)
{
     response._cmd = "roomOK"
     _server.sendResponse(response, -1, null, chan)
}


So the server joins the user into a room. If it was sucessful, it sends a "roomOK" message to the client.

Here is the client code :

Code: Select all

smartfox.onExtensionResponse = function(resObj:Object, type:String)
{
     if (resObj._cmd == "roomOK")
     {
          // Joined room sucessfully
          smartfox.sendXtMessage("dbTest", "getuniqueid", obj)   
     }
}


so when the client receives the "roomOK" the calls a server side function.... and doing so tosses this error :

09:11:59.703 - [ WARNING ] > Extension Call has invalid RoomID. User = Sparticus - /204.209.149.16

I checked within the flash console and it shows the user in the room....

any idea?

thanx
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 03 Mar 2006, 16:18

oh, and I thought I'd point out that I tried what you suggested... as you can see in the above code I added "true" to the function call to tell it to send a "onJoinRoom" event...

however I put a trace within the server side "onJoinRoom" function and it never get called.
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 03 Mar 2006, 16:39

Hmm... and when I add this code to my client side just before I issue the "smartfox.sendXtMessage"

Code: Select all

var Room = smartFox.getActiveRoom();
var temp = Room.getName();
trace(temp);


it traces as "undefined"

Obviously the client side has no clue what room it is in.... honestly though... does the client even need to know what room he is in? is it required for the client to talk to the server? As long as he is in fact in a room... I thought that is all that matters.
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 03 Mar 2006, 16:59

bah.,.. I just noticed my function call to joinRoom passed in 8 variables... it should ahve been 7.

So I now got it so that "onJoinRoom" does get called... but when I add this code to it :

Code: Select all

smartfox.onJoinRoom = function(roomObj)
{
     trace("roomobj = "+roomObj.getName());
}


it traces the room name as undefined. what did I screw up now? lol
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

Postby Sparticus » 03 Mar 2006, 17:59

Anyone? Please! I am still reading away and trying random things to get this figured out.

I'll give you a night with my girlfriend for the answer!! :wink:
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Mar 2006, 18:12

Do you send the roomList initially?

After the user is logged it would be better to send the roomList. This will create the roomList data structure on the client, which is used by all the other events such as onJoinRoom, onRoomAdded etc...

You can request it from the client side by calling smartfox.getRoomList() or you can send it from the server side.

I think the problem with your joinRoom event is because of that.
I'll give you a night with my girlfriend for the answer!!


I am sure your girlfriend will like the idea to be exchanged for a few line of code... :lol:
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 21 guests