Aw address

From ActiveWiki
Jump to navigation Jump to search
Minimum requirements
Added in version 2.2
SDKbuild 14
Worldbuild 21
Browserbuild 303


int aw_address (int session_id)

Description

Returns the IP address of a user.

Callback

AW_CALLBACK_ADDRESS

Notes

This request is resolved by the world server. Thus, the bot instance must currently be in the same world as the session being queried.

Developers should keep in mind that because of technologies such as proxy servers, it is possible for more than one user to have the same IP address at the same time. Thus it cannot always be assumed that each user's IP address is unique. Also, since a single machine can run many bots, multiple bots will often share the same IP address.

Arguments

session_id
Session number of the user whose IP address is desired.

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 instances owned by a caretaker (i.e. aw_bool (AW_WORLD_CARETAKER_CAPABILITY) returns 1), instances with eject capability (i.e. aw_bool (AW_WORLD_EJECT_CAPABILITY) returns 1) and world server administration instances are allowed to use this method.
RC_NO_SUCH_SESSION (2)
No user with a matching session number was found in the world.

(1) Possible return values when a callback is installed.

(2) Returned from the world server; and is passed to any installed callback handler.

Blocking calls may return any of the listed reason codes.

Returned attributes

AW_AVATAR_SESSION
The queried session number; this is useful for determining which callback is for which request if multiple asynchronous calls to aw_address are outstanding.
AW_AVATAR_ADDRESS (1)
IP address of the user, in network byte order.

(1) If the world server returned RC_SUCCESS.

Usage

int get_address (int session)
{
  int rc;
   
  rc = aw_address (session);
  if (rc != RC_SUCCESS)
    return -1; /* returns 255.255.255.255 when query fails */
  
  return aw_int (AW_AVATAR_ADDRESS);
}

Examples

C language

Example #1
Blocking operation.
Example #2
Asynchronous operation.