int aw_address (int session_id) |
|
aw_address returns the IP address for a given session number. Callback AW_CALLBACK_ADDRESS Notes This method requires at least SDK build 14 and world server build 21. Set session_id to the the session number of the user whose IP address is desired. This request is resolved by the world server. Thus, the SDK application must currently be in the same world as the session being queried. Also, the instance must have either Caretaker or Eject rights in the world, otherwise aw_address returns RC_UNAUTHORIZED. If session_id corresponds to a valid session number and the calling instance is authorized to call aw_address, the following attributes are returned: AW_AVATAR_SESSION AW_AVATAR_SESSION specifies the requested 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 specifies the IP address of the user, in network byte order. 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. Example
void handle_chat (void)
{
int rc;
int address;
char msg[256];
/* provide IP addresses in response to spoken requests */
if (!strcmp (aw_string (AW_CHAT_MESSAGE), "What is my address?"))
if (rc = aw_address (aw_int (AW_CHAT_SESSION)))
aw_say ("Sorry, I cannot determine your IP address");
else {
address = aw_int (AW_AVATAR_ADDRESS);
sprintf (msg, "Your IP address is %s",
inet_ntoa (*(struct in_addr*)&address);
aw_say (msg);
}
}
aw_event_set (AW_EVENT_CHAT, handle_chat);
|