androidsmartfoxserver

Sending response to multiple players in smartfox server


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..


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.