get All Users In a Zone

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 May 2009, 04:29

Sorry, I think this line:

Code: Select all

allUsers.push( _server.getUserByChannel( socketChan ) )

should like this:

Code: Select all

allUsers.push( _server.instance.getUserByChannel( socketChan ) )
Lapo
--
gotoAndPlay()
...addicted to flash games
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 13 May 2009, 09:08

With the java version, Eclipse couldn't resolve Users to a type and couldnt cast ArrayList to a LinkedList (which it apparently had to do to use .push).
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 May 2009, 12:54

Sorry, I did it from memory but I couldn't compile it in my head :)
This should work correctly:

Code: Select all

public List<Users> getAllUsersInZone()
{
   // Grab current extension zone
      Zone zone = helper.getZone(this.getOwnerZone());
   
      // Get the java list of socket channels
      List listOfChannels = zone.getAllUsersInZone();
   
      // the list of users
      List<User> allUsers = new ArrayList<Users>();

      SocketChannel socketChan;
   
      for (Object obj : listOfChannels)
      {
        socketChan = (SocketChannel) obj;
        allUsers.add( helper.getUserByChannel(socketChan) );
      }
   
   return allUsers
}
Lapo

--

gotoAndPlay()

...addicted to flash games
ryanhuynh
Posts: 1
Joined: 03 Sep 2015, 07:23

Re: get All Users In a Zone

Postby ryanhuynh » 03 Sep 2015, 07:38

i use this way for get all user in zone
List<User> arrUser = SmartFoxServer.getInstance().getUserManager().getAllUsers();
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: get All Users In a Zone

Postby Lapo » 03 Sep 2015, 08:10

ryanhuynh wrote:i use this way for get all user in zone
List<User> arrUser = SmartFoxServer.getInstance().getUserManager().getAllUsers();


That code looks like SFS2X, but this is the SFS PRO forum section :wink:
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 25 guests