Extension Error

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

Moderators: Lapo, Bax

Post Reply
reecedogcp78
Posts: 71
Joined: 12 Dec 2010, 18:16

Extension Error

Post by reecedogcp78 »

Hello,

Im extremely sorry to be annoying you today with my pathetic code but I just cannot see where I have gone wrong.

My extension is supposed to be called and then send a amount of coins back to the client at the moment the amount of coins is set to 10 as I have not yet added DB Functions, My code follows.

Code: Select all

function init()
{
        trace("Coin System Loaded");
}

function destroy()
{
        // Here we release resources before the extension is destroyed
}

function handleRequest(cmd, params, user, fromRoom)
{
if (cmd == "get")
        {
			var response = {};
                response._cmd = "coinGet"
				response.coins = "10"
                
                _server.sendResponse(response, -1, null, [user], "xml");
        }
}

function handleInternalEvent(evtObj)
{
        trace("Event: " + evtObj.name);

}
And the error I am seeing in the console:

Code: Select all

12:34:06.955 - [ WARNING ] > Error in extension [ coin.as ]: TypeError: Cannot c
all method "keySet" of null (coin.as#1192) Internal: -383 -- Line number:  (Main
Lib line: 1192)
Any help is greatly appreciated.
~Reecedog,

Experienced blogger with 100 thousand hits gathered.

New to SFS But also very good with it :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Extension Error

Post by rjgtav »

Hello.
The problem is on the client-side. You're calling that extension by using:

smartfox.sendXtMessage("Coin", "get", null);

But you can't send a null object, otherwise it will throw that error you're getting. You need to send an empty object instead, like:

smartfox.sendXtMessage("Coin", "get", {});
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Post Reply