_server.sendResponse() throwing exception when using "

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

Moderators: Lapo, Bax

Post Reply
Sandyx
Posts: 21
Joined: 06 Sep 2008, 10:54

_server.sendResponse() throwing exception when using "

Post by Sandyx »

hi

we tried to do this

Code: Select all

//sending simple string
room = _server.getCurrentRoom();
users = room.getAllUsers();
_server.sendResponse("1,2,3",room.getId(),null,users,"str")
but the error i get is

Code: Select all

09:53:50.336 - [ WARNING ] > Error in extension [ DROP_BALL.as ]: Can't find met
hod it.gotoandplay.smartfoxserver.extensions.AbstractExtension.sendResponse(stri
ng,number,null,java.util.LinkedList). (DROP_BALL.as#535) Internal: -1025 -- Line
 number:  (MainLib line: 535)

however, if we change this to [reference maze example]

Code: Select all

room = _server.getCurrentRoom();
users = room.getAllUsers();
var resO = []  // The list of params 
resO[0]="1,2,3" 
_server.sendResponse(resO,room.getId(),null,users,"str")
it works ... is this the correct way of doing this ?


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

Post by Lapo »

Since this has been asked many times and it's well documented all I should say is RTFM! ;) ( http://en.wikipedia.org/wiki/RTFM )

If you simply take a look at the examples in the _sendResponse() method of the AS API -> http://www.smartfoxserver.com/docs/docP ... /index.htm

And all the details are explained at chapter 8.6

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Sandyx
Posts: 21
Joined: 06 Sep 2008, 10:54

Post by Sandyx »

hi

ya.. had done the manual readin.. hence i had got it to work .. the question was why this would not work, more for understanding...

_server.sendResponse("Sandyx",room.getId(),null,users,"str")
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

Because the first parameter of the sendResponse expects an object or an array.

In your case, you would want to put that string inside an array, i.e.

["Sandyx"]

but you'll need a command along with it, and is usually placed in the first element of the array, i.e. ["moveMe", "Sandyx"].

In some sense, it also expect a roomId - not sure if you need to add it as well.

so, you could either have:

["moveMe", "Sandyx"] //array

or

{_cmd: "moveMe", name: "Sandyx"} //object
Smartfox's forum is my daily newspaper.
Post Reply