Room broadcast from ZoneExtension

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

pauloamorimbr
Posts: 17
Joined: 05 Nov 2010, 15:31

Room broadcast from ZoneExtension

Postby pauloamorimbr » 11 May 2012, 01:10

Hello. I have a need and just can't see how to solve it in a simple (and beautiful) way.

I have a game room that needs to push information to the clients without depending on a user sending it.

I was taking a look at all the options like sendAdminMessage, extensionResponse, etc...but none of them gives me the option to send a message (string/object) to a specific room without specifying a sender to do so, and it happens that I just doesn't have a sender, its just a server message like a timeout, for example.

Can someone give me a light on that?

My users can be in more than 1 room at the same time, and that is why I need to filter the messages by room. The ideal for me would be to call the api.sendPublicMessage(...) passing null as the sender, but it doesn't work like that.

Thanks for the help in advance.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Room broadcast from ZoneExtension

Postby Bax » 11 May 2012, 07:33

In your Extension simply use the send() method inherited from the parent BaseClientRequestHandler class.
Paolo Bax
The SmartFoxServer Team
pauloamorimbr
Posts: 17
Joined: 05 Nov 2010, 15:31

Re: Room broadcast from ZoneExtension

Postby pauloamorimbr » 11 May 2012, 15:06

Hey, Bax...thanks....but, if I'm not mistaken, the send is only available inherited BaseClientRequestHandler, as you said, and I won't be able to use the function from other events from the server, like a timed process that ended or some new input on database.

Do you know what I mean?

I'd like to send push notifications to client from any place in my code....even from a thread that is running and not caring at all about the Requests being made by the clients.

(I find it's kinda hard to explain)
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: Room broadcast from ZoneExtension

Postby Bax » 14 May 2012, 08:09

You have the same send() method on your main extension class.
Paolo Bax
The SmartFoxServer Team

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 60 guests