help with getUserList() please

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

alex2344
Posts: 6
Joined: 30 Oct 2018, 12:04

help with getUserList() please

Postby alex2344 » 28 Nov 2018, 20:53

hi
when i use getUserList() I get the following error

Code: Select all

20:47:03.693 - [ WARNING ] > Error in extension [ admin.as ]: TypeError: Cannot find function getChannel. (admin.as#526) Internal: -1049 -- Line number:  (MainLib line: 526)


the code :

Code: Select all

var userList = _server.getCurrentZone().getUserList();
var res = {};
res._cmd = "serverMsg"
res.msg = "Here's a message to a group of users"
_server.sendResponse(res, -1, null, [userList]);


I have also tried getAllUsers() without result
User avatar
Lapo
Site Admin
Posts: 20440
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: help with getUserList() please

Postby Lapo » 29 Nov 2018, 14:36

The userList variable is already an array so you don't need to wrap it in another array.
Your code:

Code: Select all

_server.sendResponse(res, -1, null, [userList]);


Correct code:

Code: Select all

_server.sendResponse(res, -1, null, userList);


Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
alex2344
Posts: 6
Joined: 30 Oct 2018, 12:04

Re: help with getUserList() please

Postby alex2344 » 29 Nov 2018, 18:50

thank you for replying
When I use :

Code: Select all

_server.sendResponse(res, -1, null, userList);


I get the following error

Code: Select all

18:50:33.244 - [ WARNING ] > Error in extension [ admin.as ]: Wrapped java.lang.ClassCastException: java.util.LinkedList cannot be cast to java.nio.channels.SocketChannel (admin.as#513) Internal: -1062 -- Line number:  (MainLib line: 513)
User avatar
Lapo
Site Admin
Posts: 20440
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: help with getUserList() please

Postby Lapo » 30 Nov 2018, 11:46

Sorry, my bad, haven't been using SFS1 in a long time.
The sendResponse method expects a native array but the getUserList() returns a Java list.

You can use a for loop to transform it and transfer all elements into a native AS array.
Lapo

--

gotoAndPlay()

...addicted to flash games
alex2344
Posts: 6
Joined: 30 Oct 2018, 12:04

Re: help with getUserList() please

Postby alex2344 » 30 Nov 2018, 14:54

It works now thanks

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 26 guests