Stops a running world.
AW_CALLBACK_ADMIN_WORLD_RESULT
This method is new in Active Worlds 3.1 and requires at least SDK build 18 and world server build 28.
This is an administration mode method and can only be used by instances created with aw_server_admin.
aw_server_world_stop stops a world that is in any state other than AW_SERVER_STOPPED (as indicated by the attribute AW_SERVER_STATE.) It will fail if the state is already AW_SERVER_STOPPED.
Stopping a world removes it from the universe so that it can no longer be accessed by users. Stopping a world also immediately disconnects any users in that world. A "friendly" application might want to check the value of AW_SERVER_USERS before stopping a world.
The various changes in a world's state resulting from this call will be indicated by the event AW_EVENT_ADMIN_WORLD_INFO.
/* code to stop any empty, running worlds in the current world server */
void handle_admin_result (int rc)
{
if (rc)
printf ("Unable to stop world: %d\n", rc);
}
void handle_world_info (void)
{
int rc;
/* if a world is running and empty, stop it. */
/* Note: it is okay to call aw_server_world_stop here
since we have installed a handler for the callback to put it
into asynchronous mode. It's not safe to call synchronous
methods from within event handlers. */
if (aw_int (AW_SERVER_STATE) != AW_SERVER_STOPPED))
if (aw_int (AW_SERVER_USERS) != 0)
printf ("World %s is currently in use, not stopping...\n",
aw_string (AW_SERVER_NAME));
else if (rc = aw_server_world_stop (aw_int (AW_SERVER_ID)))
printf ("Unable to stop world: %d\n", rc);
}
void stop_running_worlds (void)
{
int rc;
aw_callback_set (AW_CALLBACK_ADMIN_WORLD_LIST, NULL);
aw_callback_set (AW_CALLBACK_ADMIN_WORLD_RESULT, handle_admin_result);
aw_event_set (AW_EVENT_ADMIN_WORLD_INFO, handle_world_info);
aw_int_set (AW_SERVER_ID, 0);
do
if (rc = aw_server_world_list ()) {
printf ("Unable to query world list (reason %d)\n", rc);
break;
}
while (aw_bool (AW_SERVER_MORE));
}
aw_server_admin
aw_server_world_add
aw_server_world_change
aw_server_world_delete
aw_server_world_list
aw_server_world_set
aw_server_world_start