Vp login: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Roy Curtis (talk | contribs)
m method templates
Sleepy E (talk | contribs)
mNo edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{sdk method page|login|Logs in a bot to the [[universe]] server, using the credentials of an existing account.
{{sdk method page|login| Login to the universe server; using the credentials of an existing user account.
|paramex=username, password, botname
|paramex=username, password, botname
|parameters=
|parameters=
   {{sdk parameter row|string|username|Username of the account to log into}}
   {{sdk parameter row|string|username|Use credentials of the account with this name}}
   {{sdk parameter row|string|password|Password of the account to log into}}
   {{sdk parameter row|string|password|Password associated with the account}}
   {{sdk parameter row|string|botname |Desired name for the bot to use}}
   {{sdk parameter row|string|botname |Name that the bot will appear with in a world. There are no restrictions on what characters can be used.}}
|returncodes=
|returncodes=
   {{sdk return code row|NOT_INITIALIZED|SDK not initialized with {{sdk method|init}} yet}}
   {{sdk return code row|STRING_TOO_LONG |If any of the given string parameters exceed 255 bytes in length (when using UTF-8 encoded characters they can each be multiple bytes long)}}
   {{sdk return code row|INVALID_LOGIN  |The login credentials are incorrect}}
  {{sdk return code row|INVALID_LOGIN  |The login credentials are incorrect}}
  {{sdk return code row|TIMEOUT        |Timeout}}
   {{sdk return code row|NOT_IN_UNIVERSE |Universe request made while not connected to a universe server}}
|returnattributes=
  {{sdk attribute row|int|my_user_id|User id of account used to log in}}
|behavior=
|behavior=
*If a {{sdk callback|login}} callback is set this function will return immediately and return the result using the callback, otherwise it will call {{sdk method|wait}} in a loop until done.
* When successfully logged in, bots will have square brackets around their name. For example, providing "Samantha" as the {{code|botname}} parameter will identify the bot as "[Samantha]".
* When successfully logged in, bots will have square brackets around their name. For example, providing "Samantha" as the {{code|botname}} parameter will identify the bot as "[Samantha]".
* The user ID of the account used to log in will be exposed to other bots
* The user ID of the account used to log in will be exposed to other users.
|caveats=To log out from a universe, {{sdk method|destroy}} must be called which will also disconnect the bot from the universe.
* Bot names that contain [https://wikipedia.org/wiki/UTF-8 UTF-8] encoded characters (e.g. "\xE2\x98\xAF" is the "Yin and Yang" symbol ☯) will display correctly in a browser.
|caveats=
* To log out from a universe, {{sdk method|destroy}} must be called which will also disconnect the bot from the world.
* If calling this while already logged in and entered into a world, then it will not update the identity of the bot inside the world (nor will it disconnect). Need to call {{sdk method|enter}} for the identity in world to update.
|examples=
<syntaxhighlight lang="c">
int rc;
 
rc = vp_login(sdk, "myname", "mypassword", "botname");
if (rc)
  printf("Couldn't login (reason %d)\n", rc);
</syntaxhighlight>
|seealso=
|seealso=
* {{sdk callback|login}}
* {{sdk method|destroy}}
* {{sdk method|destroy}}
* {{sdk method|enter}}
* {{sdk method|enter}}
}}
}}

Latest revision as of 21:55, 1 August 2018

Method call snippet vp_login(instance, username, password, botname);
Login to the universe server; using the credentials of an existing user account.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
string
username
Use credentials of the account with this name
string
password
Password associated with the account
string
botname
Name that the bot will appear with in a world. There are no restrictions on what characters can be used.

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)
VP_RC_STRING_TOO_LONG If any of the given string parameters exceed 255 bytes in length (when using UTF-8 encoded characters they can each be multiple bytes long)
VP_RC_INVALID_LOGIN The login credentials are incorrect
VP_RC_TIMEOUT Timeout
VP_RC_NOT_IN_UNIVERSE Universe request made while not connected to a universe server

The following attributes will be returned in VP_CALLBACK_LOGIN if the operation was successful:

Attribute Usage Also returned for
VP_MY_USER_ID User id of account used to log in

Behavior

  • If a VP_CALLBACK_LOGIN callback is set this function will return immediately and return the result using the callback, otherwise it will call vp_wait() in a loop until done.
  • When successfully logged in, bots will have square brackets around their name. For example, providing "Samantha" as the botname parameter will identify the bot as "[Samantha]".
  • The user ID of the account used to log in will be exposed to other users.
  • Bot names that contain UTF-8 encoded characters (e.g. "\xE2\x98\xAF" is the "Yin and Yang" symbol ☯) will display correctly in a browser.

Caveats

  • To log out from a universe, vp_destroy() must be called which will also disconnect the bot from the world.
  • If calling this while already logged in and entered into a world, then it will not update the identity of the bot inside the world (nor will it disconnect). Need to call vp_enter() for the identity in world to update.

Examples

int rc;

rc = vp_login(sdk, "myname", "mypassword", "botname");
if (rc)
  printf("Couldn't login (reason %d)\n", rc);

See also