Vp connect universe: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Sleepy E (talk | contribs)
m Callback
Sleepy E (talk | contribs)
mNo edit summary
Line 2: Line 2:
|paramex="universe.virtualparadise.org", 57000
|paramex="universe.virtualparadise.org", 57000
|parameters=
|parameters=
   {{sdk parameter row|string|host|Hostname of uniserver; typically {{code|"universe.virtualparadise.org"}}}}
   {{sdk parameter row|string|host|Host address of server to connect to; typically {{code|"universe.virtualparadise.org"}}}}
   {{sdk parameter row|int  |port|Port of uniserver; typically {{code|57000}}}}
   {{sdk parameter row|int  |port|TCP port of remote server; typically {{code|57000}}}}
|returncodes=
|returncodes=
   {{sdk return code row|NOT_INITIALIZED|SDK not initialized with {{sdk method|init}} yet}}
   {{sdk return code row|connection_error|Error connecting to the universe server}}
  {{sdk return code row|CONNECTION_ERROR|Error connecting to the universe server}}
|behavior=
|behavior=
* If a {{sdk callback|CONNECT_UNIVERSE}} 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.
* If a {{sdk callback|connect_universe}} 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.
|caveats=To disconnect from a universe, {{sdk method|destroy}} must be called.
|caveats=To disconnect from a universe, {{sdk method|destroy}} must be called.
|examples=
|examples=
<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
int rc;
int rc;
if(rc = vp_connect_universe(instance, "universe.virtualparadise.org", 57000))
 
     printf("Error connecting to universe (reason %d)\n", rc);
rc = vp_connect_universe(instance, "universe.virtualparadise.org", 57000);
if(rc)
     printf("Couldn't connect to universe(reason %d)", rc);
</syntaxhighlight>
</syntaxhighlight>
|seealso=
|seealso=

Revision as of 19:38, 16 December 2016

Method call snippet vp_connect_universe(instance, "universe.virtualparadise.org", 57000);

Connects an instance to a universe server. Required before an instance log in with user credentials and connects to any world.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
string
host
Host address of server to connect to; typically "universe.virtualparadise.org"
int
port
TCP port of remote server; typically 57000

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_CONNECTION_ERROR Error connecting to the universe server

Behavior

  • If a VP_CALLBACK_CONNECT_UNIVERSE 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.

Caveats

To disconnect from a universe, vp_destroy() must be called.

Examples

int rc;

rc = vp_connect_universe(instance, "universe.virtualparadise.org", 57000);
if(rc)
    printf("Couldn't connect to universe(reason %d)", rc);

See also