GetAllUsersButOne ?

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

Moderators: Lapo, Bax

Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

GetAllUsersButOne ?

Postby Fishypants » 09 May 2015, 03:20

Hey! So I was using Smartfox Server 1.6x and there was a handy function (it might have been undocumented) called getAllUsersButOne(int userIndex) which was a nice convenient way of getting a list of users in a room but excluding one of the users (usually the user who sent the extension request) so you could send a message to all of the users but 1 of them.

So if a user wanted to broadcast a message to all the other users in the room, it was a nice easy way to set that up.

Now we are using Smartfox Server 2X and I can't seem to find anything equivalent to that function. At the moment, I wrote my own that will get a list of all the users in the room, go through each one and check if it was the same user that sent the request, and if so it removes them from the list. Which is fine, but if there is a function that will do it all for me and keep my code cleaner, that would be awesome.

Is there such a function?
User avatar
Lapo
Site Admin
Posts: 21639
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: GetAllUsersButOne ?

Postby Lapo » 09 May 2015, 07:30

Hi,
there isn't such functionality, but it's extremely simple to implement:

Code: Select all

List<User> peopleInRoom = room.getUserList();
peopleInRoom.remove(someUser);


Where the 1st line obtains the list of users inside a Room and the next removes one user from the list before we proceed with doing something with it (the list)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Re: GetAllUsersButOne ?

Postby Fishypants » 09 May 2015, 18:57

Hmmm, that is way simpler than what I currently have. Thanks for the tip Lapo! :D

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 36 guests