Post here your questions about Actionscript and Java server side extensions development.
Moderators: Lapo , Bax
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 22 Aug 2007, 21:11
Hello.
I'm trying to send a response to all users in a room, but when i try the code below (the code is server side):
Code: Select all
var usersArray = _server.getCurrentRoom().getAllUsers();
room = _server.getCurrentRoom()
usersInRoom = room.getAllUsers()
_server.sendResponse(response, -1, null, usersInRoom);
I'm getting this error on the server:
Code: Select all
2007/08/22 22:35:47.843 - [ WARNING ] [id: 11] (JavascriptExtension.logASError): Error in extension [ myExt.as ]:
Please help.
Thanks.[/quote]
Lapo
Site Admin
Posts: 23438 Joined: 21 Mar 2005, 09:50
Location: Italy
Post
by Lapo » 23 Aug 2007, 06:45
Try running this code:
Code: Select all
var room = _server.getCurrentRoom()
trace("room: " + room)
usersInRoom = room.getAllUsers()
trace("users: " + usersInRoom)
and tell us what it outputs
thanks
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 23 Aug 2007, 09:39
Thanks Lapo,
I get the same error:
Code: Select all
2007/08/23 11:05:19.921 - [ WARNING ] [id: 11] (JavascriptExtension.logASError): Error in extension [ myExt.as ]: TypeError: Cannot call method "getAllUsers" of null (myExt.as#1421) Internal: 91 -- Line number: 91 in file: myExt.as
Lapo
Site Admin
Posts: 23438 Joined: 21 Mar 2005, 09:50
Location: Italy
Post
by Lapo » 23 Aug 2007, 09:51
mmm...
it seems that the error is clearer now.
You should check line 91 of myExt.as and look for a null object, where you're probably expecting a Room object
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 23 Aug 2007, 16:00
line 91 is this:
var room = _server.getCurrentRoom()
trace("room: " + room)
usersInRoom = room.getAllUsers()
trace("users: " + usersInRoom)
_server.sendResponse(response, -1, null, usersInRoom);
The output of this trace on line 90:
trace("room: " + room)
is:
"room: null"
I'm calling the handleRequest function on the server from the client side:
smartfox.onJoinRoom = function(roomObj:Room) function
I do not know what's going wrong?
Any more help would be really great. Thanks.
[/code]
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 23 Aug 2007, 16:16
All i really want to do, is send a server response to all users in the current room? using actionscript, server side
Thanks again.
patso
Posts: 380 Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria
Post
by patso » 23 Aug 2007, 16:26
If the extension is zone level the _server.getCurrentRoom() always return null so when you call room.getAllUsers() you get this error.
Not 100% sure but I think this is the problem.
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 23 Aug 2007, 16:54
patso -- You are right, this is a zone level extension.
How can i use the fromRoom object to get the users in that roon then?
Code: Select all
function handleRequest(cmd, params, user, fromRoom) {
fromRoom.getAllUsers();
Somthing like that would be great.
Cheers.
patso
Posts: 380 Joined: 13 Nov 2006, 13:44
Location: Sofia, Bulgaria
Post
by patso » 24 Aug 2007, 06:25
try this:
Code: Select all
usersInRoom = _server.getCurrentZone().getRoom(fromRoom).getAllUsers();
poppop
Posts: 57 Joined: 07 Jul 2007, 10:24
Post
by poppop » 24 Aug 2007, 10:00
Thanks for all the help guys!!!
patso -- your code worked perfect, thanks so much!