ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
callbacks (Sdk)
callbacks // Sdkjan-willem de bleserOct 3, 1998, 5:02pm
This is a multi-part message in MIME format.
--------------F360428F268B33A9BFB406E4 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Ok. Ive looked over all the docuentation but i still cant figure out what a callback is. can someone explain to me what it is and how to use it? --------------F360428F268B33A9BFB406E4 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jan-willem De Bleser Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Jan-willem De Bleser n: De Bleser;Jan-willem org: High school email;internet: debleser at mediaone.net x-mozilla-cpt: ;0 x-mozilla-html: FALSE version: 2.1 end: vcard --------------F360428F268B33A9BFB406E4-- jeanphiOct 4, 1998, 8:17am
Hi,
If I well understood, the callbacks are functions that allow you to get info from the server. like aw_world list_list seems to send you the list of worlds running on the universe you are in. jeanphi netropolisOct 4, 1998, 10:05am
Basically, a callback is a function pointer which is used to call a
function. Check the following code... /* pointer to a function */ void (*afunction)(int); /* callback installer */ void set_callback(void (*acallback)(int)) { afunction = acallback; } /* callback caller */ void call_callback(int a) { afunction(a); } /* function to install as a callback */ void mycallback(int a) { printf("a=%d\n", a); } void main(void) { set_callback(mycallback); call_callback(1); } This is a generic example to show how callbacks work, too much work just to print "a=1" :)) Using the AW SDK, you don't have to implement the "set_callback" and "call_callback" functions. You have to write the function that will be installed as callback using "aw_callback_set", the SDK is responsible for calling it. Check http://www.activeworlds.com/sdk/asynchro.htm HTH, -Netro jan-willem de bleserOct 5, 1998, 7:10pm
This is a multi-part message in MIME format.
--------------6E497948E93E4073BCF2125C Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit but the function returns the info itself. i reread it a few times and it seems like you can tell the function to return before it is done so you can continue the rest of the program. the data is then recieved later. [View Quote] > Hi, > > If I well understood, the callbacks are functions that allow you to get info > from the server. > > like aw_world list_list seems to send you the list of worlds running on the > universe you are in. > > jeanphi --------------6E497948E93E4073BCF2125C Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jan-willem De Bleser Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Jan-willem De Bleser n: De Bleser;Jan-willem org: High school email;internet: debleser at mediaone.net x-mozilla-cpt: ;0 x-mozilla-html: FALSE version: 2.1 end: vcard --------------6E497948E93E4073BCF2125C-- edward sumerfieldOct 7, 1998, 12:23am
There is practically no difference between callbacks and aw_event_set
functions. Its just a way for the SDK to call your code. I don't understand why the SDK implements them using different mechanisms. Netropolis said it all. Edward Sumerfield. [View Quote] roland vilettOct 7, 1998, 2:41pm
>There is practically no difference between callbacks and aw_event_set
>functions. Its just a way for the SDK to call your code. > >I don't understand why the SDK implements them using different mechanisms. There is a conceptual difference. Callbacks occur in order to report the results to you of specific actions that your app has triggered, e.g. adding an object, looking up a citizen, etc. Success or failure of the request is common to all callbacks, thus the callback functions take a single int rc argument. Meanwhile, events can happen at any time, not necessarily in response to your application's actions. They don't have a concept of succeeding or failing, thus the event handlers do not take any arguments. -Roland jan-willem de bleserOct 7, 1998, 7:09pm
This is a multi-part message in MIME format.
--------------C509948BEBF1FFF67AEC1054 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Roland, can you please slowly explain how to use callbacks and where to use them? [View Quote] > > There is a conceptual difference. Callbacks occur in order to report the > results to you of specific actions that your app has triggered, e.g. adding > an object, looking up a citizen, etc. Success or failure of the request is > common to all callbacks, thus the callback functions take a single int rc > argument. Meanwhile, events can happen at any time, not necessarily in > response to your application's actions. They don't have a concept of > succeeding or failing, thus the event handlers do not take any arguments. > > -Roland --------------C509948BEBF1FFF67AEC1054 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jan-willem De Bleser Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Jan-willem De Bleser n: De Bleser;Jan-willem org: High school email;internet: debleser at mediaone.net x-mozilla-cpt: ;0 x-mozilla-html: FALSE version: 2.1 end: vcard --------------C509948BEBF1FFF67AEC1054-- roland vilettOct 7, 1998, 11:06pm
I did the best job I can do of explaining callbacks in the "Asynchronous
Operation" section of the SDK docs: http://www.activeworlds.com/sdk/asynchro.htm -Roland [View Quote] jan-willem de bleserOct 7, 1998, 11:32pm
This is a multi-part message in MIME format.
--------------587F2BB06951694049714AB6 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit whats Asynchronous Operation? [View Quote] > I did the best job I can do of explaining callbacks in the "Asynchronous > Operation" section of the SDK docs: > > http://www.activeworlds.com/sdk/asynchro.htm > > -Roland > [View Quote] --------------587F2BB06951694049714AB6 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jan-willem De Bleser Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Jan-willem De Bleser n: De Bleser;Jan-willem org: High school email;internet: debleser at mediaone.net x-mozilla-cpt: ;0 x-mozilla-html: FALSE version: 2.1 end: vcard --------------587F2BB06951694049714AB6-- edward sumerfieldOct 8, 1998, 2:07am
Time to take a programming coarse.
Synchronous operation is one thing after another. Asynchronous operation is many things at once. Well, kind of. Lets use a little bit of psuedo code. Sync operation: while do forever do this thing and wait done Async operation: while do forever do this thing and while it is doing it return. /* so the thing is still goint but this code is continuing anyway. */ do another thing. done How about an example. You want to read a message from a communications line. You can call a read function and wait for data to arrive at your machine, sync operation. Or you can call a read function to indicate that you wand date but then return. Now while you are waiting for data to arrive you can be doing something else. When the data arrives the other part of your program calls you. I think I may be making things more complicated than they need to be. Sorry. The aw sdk. aw_callback_set(function); aw_query while () do something. } function() { this will be called when the query operation is complete. } You know, if you don't need to get into higher efficiency bots I would just ignore the issue. Edward Sumerfield. [View Quote] jan-willem de bleserOct 8, 1998, 9:19am
This is a multi-part message in MIME format.
--------------71E1C7B33A6FC123844103F5 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit actually, you helped. thanks [View Quote] > Time to take a programming coarse. > > Synchronous operation is one thing after another. > Asynchronous operation is many things at once. > > Well, kind of. Lets use a little bit of psuedo code. > > Sync operation: > > while do forever > > do this thing and wait > done > > Async operation: > > while do forever > > do this thing and while it is doing it return. > > /* so the thing is still goint but this code is continuing anyway. > */ > > do another thing. > done > > How about an example. > > You want to read a message from a communications line. You can call a read > function and wait for data to arrive at your machine, sync operation. Or you > can call a read function to indicate that you wand date but then return. Now > while you are waiting for data to arrive you can be doing something else. > When the data arrives the other part of your program calls you. > > I think I may be making things more complicated than they need to be. Sorry. > > The aw sdk. > > aw_callback_set(function); > aw_query > while () > > do something. > } > > function() { > > this will be called when the query operation is complete. > } > > You know, if you don't need to get into higher efficiency bots I would just > ignore the issue. > > Edward Sumerfield. > [View Quote] --------------71E1C7B33A6FC123844103F5 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Jan-willem De Bleser Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Jan-willem De Bleser n: De Bleser;Jan-willem org: High school email;internet: debleser at mediaone.net x-mozilla-cpt: ;0 x-mozilla-html: FALSE version: 2.1 end: vcard --------------71E1C7B33A6FC123844103F5-- |