SDK Application Structure
A typical SDK application has the following organization:
- Event Loop
- Call aw_wait and respond to events
- Shut Down
Applications do not necessarily need to follow this structure. However all applications must call aw_init before calling any other API methods and call aw_create at least once in order to create an instance.
An instance refers to a single login session within Active Worlds. Each session has a single connection to the universe server as well as an additional optional connection to a single world server. For example, each time you run the Active Worlds Browser it creates one instance for your login session. A single instance can only be at a single location in a single world at any one time, however an SDK application can create and manage many instances at once.
Instances are allocated and initialized for the application by aw_create, and are destroyed by aw_destroy. Applications that only use a single instance (the "typical" case) are the easiest to write and do not need to worry about storing or managing the instance handle that is returned by aw_create. Applications that use multiple instances need to keep track of the instance handles returned by aw_create and must use aw_instance_set to specify which instance each particular operation is intended for.
Example: Botware Inc. wants to have two bots in their world stationed at two different locations, but which share common knowledge of which users have spoken to which bot. Botware implements their bots using a single SDK application which calls aw_create, aw_login, and aw_enter twice, once for each bot.
An instance must have an owner. An owner is the Active Worlds citizen who owns and is responsible for the instance. The owner is identified during the call to aw_create by his or her citizen number and privilege password. Keep in mind that a single citizen can only have a limited number of bot instances running in the universe at any one time (typically the limit is 3 although it can be adjusted by the universe administrator.) The instance owner's citizen number is used to determine permissions and object ownership (if the SDK application builds objects) as if the instance were a regular citizen. Note that an owner does not need to be logged in in order for his or her bots to run.
Example: Botware Inc. would like their bots to be able to modify signs in their world to point to different advertisers, but they don't want the public to be able to build in their world. To do this, they have their bots log in as owned by citizen Botware, who has build rights in their world according to the world options.
Note that SDK applications are neither citizens nor tourists, they are a separate class of Active Worlds user. Typically, we just refer to them as "bots."