Page 1 of 1

Extension Error

Posted: 02 Apr 2012, 10:35
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.

Re: Extension Error

Posted: 02 Apr 2012, 16:19
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", {});