int aw_server_world_start (int id)

DESCRIPTION

Attempts to start the given world.

CALLBACK

AW_CALLBACK_ADMIN_WORLD_RESULT

NOTES

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_start changes the state of a world in the AW_SERVER_STOPPED state (as indicated by the attribute AW_SERVER_STATE) to AW_SERVER_STARTING.  It will fail if the world is in any state other than AW_SERVER_STOPPED.  A server in the AW_SERVER_STARTING state will attempt to start by sending its name and password to the universe server.   If the world identity is valid, the world will start and its state will become AW_SERVER_RUNNING.   If the start attempt fails, AW_SERVER_STATE will return to AW_SERVER_STOPPED and AW_SERVER_START_RC will indicate the reason for the failure. 

The various changes in a world's state resulting from this call will be indicated by the event AW_EVENT_ADMIN_WORLD_INFO.

EXAMPLE

/* code to restart any stopped worlds in the current world server */

void handle_admin_result (int rc)
{

  if (rc)
    printf ("Unable to start world: %d\n", rc);

}

void handle_world_info (void)
{

  /* if a world is stopped, try to start it. */
  /* Note: it is okay to call aw_server_world_start 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))
    aw_server_world_start (aw_int (AW_SERVER_ID));

}

void start_stopped_worlds (void)
{

  int rc;

  /* restart any worlds in the stopped state */
  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));

}

SEE ALSO

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_stop