onObjectReceived in zones

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

Moderators: Lapo, Bax

Aiidenb
Posts: 263
Joined: 16 Aug 2010, 22:08
Location: England
Contact:

onObjectReceived in zones

Postby Aiidenb » 10 Jul 2014, 21:56

Hello.

I'm trying to show a popup to everyone in the zone, however whenever I use the smartfox.onObjectReceived function, it only shows the popup to the people in the same room.

How can I make a popup show for everyone in the same zone, and not just the same room?

I've noticed that the admin message popup is a function.

Code: Select all

smartfox.onAdminMessage = function(msg:String, user:User) {
_root.box._visible = true;
_root.box.text = msg;
};

would there be a possible way to make my own such as

Code: Select all

smartfox.onPublicPopup = function (obj){
if(obj == "test"){
_root.box._visible = true;
_root.box.text = "All users have received this message in this zone.";
}
}



Thanks, Aiden. :)
Quackbay - The online virtual world for kids!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: onObjectReceived in zones

Postby rjgtav » 11 Jul 2014, 12:31

Hello,

Yes, the onObjectReceived event works only at the Room level.
If you want to send a message to the entire Zone, you have to use either an extension, a moderator message or an admin message (which also requires an extension).
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Aiidenb
Posts: 263
Joined: 16 Aug 2010, 22:08
Location: England
Contact:

Re: onObjectReceived in zones

Postby Aiidenb » 13 Jul 2014, 23:18

Hey, thanks for the reply.

I'm a little stuck with extensions, could you maybe show an example of how to use an extension to show a popup in all rooms?

Thanks. :)
Quackbay - The online virtual world for kids!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: onObjectReceived in zones

Postby rjgtav » 14 Jul 2014, 01:42

Hello,

I'm sorry but I don't have the time to show you an example of that in action. But I can explain you what strategy to use.
If you want to use extensions, then you can read more about how they work and how they interact with the server at:
- www.smartfoxserver.com/docs/1x/docPages ... /index.htm
- www.smartfoxserver.com/docs/1x/docPages ... /index.htm

On the second link, you'll find a basic client -> extension -> client interaction.

If you want to send a message to all users logged in a Zone, then you just have to send the extension response to all those users, instead of sending it to only 1 user.
To get all the users in a Zone from an extension you can use the getUserList() method of the specific Zone instance.
For more information, you can also read: http://www.smartfoxserver.com/docs/1x/d ... s/Zone.htm
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 52 guests