Question

Guys I want to send responses to all the players in a room at the same time..say for ex:about a certain players score update etc..I do know how to send it from the server in response to an extension request..My client side is being coded in android environment..

List<User> r=player.getRoomJoined().getUsersList();
    ext.send("handler_response_id",params,player.getRoomJoined().getUsersList());

But i do not understand how to recieve this response at the client side..There are other ways to do so as well like.

temporary being a moderator and sending a moderator message to all players in that room..but many experts have advised not to use "MODERATOR_MESSAGE" event for these purposes..If someone has worked with this..plz do help guys..I'm in a real pinch here..Any ideas or help appreciated..Thanks a lot in advance..

Was it helpful?

Solution

I'm relatively new to SFS too, but if you want to update something like a score to all players, can't you simply use a Room Variable or User Variable to do this? Then simply add a listener and handle the event SFSEvent.ROOM_VARIABLES_UPDATE. You can also set user variables on the server-side afaik, so you don't have to leave the responsibility for scores up to the client.

If you want to use events instead of variables, I believe you have to register the event type listener on the client side. Same applies for other variable updates:

sfs.addEventListener(SFSEvent.USER_VARIABLES_UPDATE, onUserVarsUpdate);

Also quick look at the API documentation here

http://docs2x.smartfoxserver.com/api-docs/javadoc/client/

Seems to have some promising event types like OBJECT_MESSAGE.

Hope this was of any help.

OTHER TIPS

There is another simple way to do this..

Zone myzone;

@Override
    public void handleClientRequest(User user, ISFSObject isfso) 
{
 myzone=getParentExtension().getParentZone();

// do whatever you want here..ie the server code..

// and while sending the response..

  List<User> recipients=(List<User>)myzone.getUserList();
                 ade=(AdminExtension) getParentExtension();
                 ade.send("10", respobj, recipients);

}

for updating to all user you can use send() to communicate or update about some event... I Hope you understand...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top