sendObject between rooms not possible?

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

Moderators: Lapo, Bax

Hexe
Posts: 3
Joined: 17 Oct 2009, 11:17

sendObject between rooms not possible?

Postby Hexe » 17 Oct 2009, 11:30

Hi!

I wanted to send messages to the users waiting in the lobby about what is happening in running games.

Imagine player1 and player2 are searching the "holy grail" in the game room and if one of them finds it, the other ones in the lobby should know about it and get a message like "player2 found the holy grail!".

I tried the obvious:
I sent a smartfox-Object with sendObject from the game-room to the lobby-room (I used the Room-ID of the lobby room, of course)
In the lobby-room the onObjectReceived-handler should wait for those mesages.

sendObject is invoked, but no messages arrive in the lobby! not even in the debug-output from Smartfox itself. So it seems the message doesn't even get to the server and is filtered out somewhere either in the clients or the server itself.

Did I miss something? I read the docs of course but didn't find anything about restrictions like not allowing to send messages between rooms. Or do I have to alter the Zone-Settings? I started off using the Zone settings of the "tic tac toe" game.

Any help would be appreciated!
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Oct 2009, 07:47

Hi,
sendObject works in the same Room.
If User A sends data to User B which is not in the same Room, data will get there but User B will not be able to know who has sent the data. This is because he's not "physically" joined to that Room, and he doesn't "see" the sender.
To put it in developer's words, their are not in the same scope.

You have multiple solutions to this:
1- simply add the sender user data in the object that's being sent
2- use a server side extension, and customize the data being sent by adding details on the sender User.
3- join both users in the same room
Lapo
--
gotoAndPlay()
...addicted to flash games
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 28 Oct 2009, 10:49

Hello Lapo,

I'm curious about this: sendObject will always send the object to everyone connected into server, but without know who is the sender? Or it just send for the people connected in that room?

I'm making a game where players create rooms and can play with 4 friends max, I will use lots of sendObjects... for the people to exchange this between then, its good... but if someone send a object and it will be received by everyone connected, I will have an infernal lag :lol:

I read at the docs but did not find a good answer... can you help?
Thanks in advance.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 28 Oct 2009, 11:32

I'm curious about this: sendObject will always send the object to everyone connected into server, but without know who is the sender? Or it just send for the people connected in that room?

The sendObject sends data to all people inside the same Room
Alternatively you can use sendObjectToGroup, which accepts a custom list of recipients (in that same Room)

I'm making a game where players create rooms and can play with 4 friends max, I will use lots of sendObjects... for the people to exchange this between then, its good... but if someone send a object and it will be received by everyone connected, I will have an infernal lag

No you won't, the data will only go to the other players.
Lapo

--

gotoAndPlay()

...addicted to flash games
kaligus
Posts: 45
Joined: 01 Sep 2009, 13:26

Postby kaligus » 28 Oct 2009, 14:39

Thats nice, thanks.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 74 guests