Aw server world stop
Minimum requirements | ||
---|---|---|
Added in version 3.1 | ||
SDK | build 18 | |
World | build 28 |
int aw_server_world_stop (int id)
Description
Stops a world.
Callback
AW_CALLBACK_ADMIN_WORLD_RESULT
Notes
This method 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.
Arguments
- id
- Unique id number of a particular world configuration.
Argument attributes
None
Return values
- RC_SUCCESS (1) (2)
- RC_NOT_INITIALIZED (1)
- RC_NO_INSTANCE (1)
- RC_NO_CONNECTION (1)
- Network connection to the world is down.
- RC_UNAUTHORIZED (2)
- Only world server administration instances are allowed to use this method.
- RC_NO_SUCH_LICENSE (2) (3)
- No world configuration with a matching id was found.
- RC_NO_SUCH_WORLD (2)
- No started world configuration with a matching id was found.
(1) Possible return values when a callback is installed.
(2) Returned from the world server; and is passed to any installed callback handler.
(3) Not used in version 4.1 and later.
Returned attributes
Usage
Stop any empty worlds that are running on the current world server.
void handle_admin_result (int rc) { if (rc != RC_SUCCESS) printf ("Unable to stop world (reason %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 { rc = aw_server_world_stop (aw_int (AW_SERVER_ID)); if (rc != RC_SUCCESS) printf ("Unable to stop world (reason %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 { rc = aw_server_world_list (); if (rc != RC_SUCCESS) { printf ("Unable to query world list (reason %d)\n", rc); break; } } while (aw_bool (AW_SERVER_MORE)); }