internal db example

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

Moderators: Lapo, Bax

User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

internal db example

Postby csharpjava » 12 Mar 2008, 19:30

(AS2 examples) internal db example : how does that work?

i read all the docs that the website offered, but where does it call the sql script.

i only noticed that it called something like "getList", but WHAT is that pointing too???

i think i just need a simple global explanation of whats going on and i can figure out the details.

THANKS!

(i have some but limited experience with databases, just enough to get by really, thx again)
Rutter
Posts: 99
Joined: 12 Dec 2007, 16:21
Location: Canada
Contact:

Postby Rutter » 12 Mar 2008, 20:52

The sql is in the server side extension. Note the following function:

function handle_getData_click():Void
{
smartfox.sendXtMessage("h2db_ext", "getList", {})
}


The sql statement is inside the extension. See the H2 database tutorial.
User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

Postby csharpjava » 13 Mar 2008, 01:10

Rutter wrote:The sql is in the server side extension. Note the following function:

function handle_getData_click():Void
{
smartfox.sendXtMessage("h2db_ext", "getList", {})
}


The sql statement is inside the extension. See the H2 database tutorial.


see that's exactly my question. given that.. how does it know to point to the "internalDbDemo" in the sfsExtensions

so far i understand this is happening:

1)smartfox.sendXtMessage("h2db_ext", "getList", {})
2) ?
3) internalDbDemo.as is called
4) dbase = _server.getDatabaseManager() is called
5) ^ ?
6) internalDbDemo.as then calls SQL script to get rows from DB and returns them to internalDbExample.fla


so does anybody knows what happens in between steps 1 and 3
and likewise steps 4 and 6?
Rutter
Posts: 99
Joined: 12 Dec 2007, 16:21
Location: Canada
Contact:

Postby Rutter » 13 Mar 2008, 02:44

Hope I understand your question because I think your first question in the thread is different then your last question.

1. The zone was created in the config.xml file.
<Extensions>
<extension name="h2db_ext" className="internalDbDemo.as" type="script" />
</Extensions>

So if you ask for "h2db_ext" extension it will then know to use "internalDbDemo.as" server extension file because that is what you have defined in the zone config file. Is that the answer your were looking for? It seems from your last response that you know that but Im not sure.

As far as the order of things

"4) dbase = _server.getDatabaseManager() is called" this has already happened when the extension was initialized. Instead perhaps #4 should be...

#4) function handleRequest(cmd, params, user, fromRoom) is called

The server extension has the handleRequest function fired and checks to see if the cmd sent equals "getList"

if (cmd == "getList")

if true then runs

function sendComputerList(user) which will run the sql script.


so to redefine your order of things
dbase = _server.getDatabaseManager() already initialized

1)smartfox.sendXtMessage("h2db_ext", "getList", {})
2) internalDbDemo.as is called (as defined in your config.xml file)
3)function handleRequest(cmd, params, user, fromRoom) in internalDbDemo.as is run
4) if cmd=="getList" it runs function sendComputerList
5) builds response object and returns to client



Does that help?
User avatar
csharpjava
Posts: 16
Joined: 23 Feb 2008, 03:20

Postby csharpjava » 13 Mar 2008, 12:41

^ Yes! That helped a ton. :)

I had no idea that the config.xml file contained

Code: Select all

<extension name="h2db_ext" className="internalDbDemo.as" type="script" />


and your ordering of 1-5 really simplified it for me too. thanks.


i guess this begs another question: (I'll test this when i have the chance)
but until then, does anybody know if this client would be able to perform this action remotely or is this a server side call only? this->

Code: Select all

smartfox.sendXtMessage("h2db_ext", "getList", {})

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: Google [Bot] and 15 guests