Vp wait: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Roy Curtis (talk | contribs)
Created page with "{{sdk method page|wait|Pumps incoming and outgoing network activity and fires any world server events. Required for most in-world method calls (e.g. {{sdk method|say}}) and ev..."
 
Roy Curtis (talk | contribs)
clarification
Line 1: Line 1:
{{sdk method page|wait|Pumps incoming and outgoing network activity and fires any world server events. Required for most in-world method calls (e.g. {{sdk method|say}}) and events to actually happen.
{{sdk method page|wait|Pumps incoming and outgoing network traffic and fires any registered events. Required for most in-world method calls (e.g. {{sdk method|say}}) and events to actually happen.
|paramex=1000
|paramex=1000
|parameters=
|parameters=
Line 6: Line 6:
   {{sdk return code row|NOT_INITIALIZED|SDK not initialized with {{sdk method|init}} yet}}
   {{sdk return code row|NOT_INITIALIZED|SDK not initialized with {{sdk method|init}} yet}}
|behavior=
|behavior=
* This will only pump for up to the amount of milliseconds, with no predictable count of how much data is sent
* This will attempt to send all pending messages and receive all pending data within the given time limit
* All [[:Category:SDK events|SDK events]] are fired from this method call
* All [[:Category:SDK events|SDK events]] are fired from this method call
* If a value of {{code|0}} is passed, it will at least pump once or fire any event once
* If a value of {{code|0}} is passed, it could still fire a number of different events
* If there is nothing left to pump (e.g. no events to fire or data to send), it will immediately return and not sleep for the remainder of the given time
* If there is nothing to handle, it will wait until the time limit. Else, it will return immediately after handling all pending data
|caveats=
|caveats=
This method should never be called inside an event handler originating from a previous {{sdk method|wait}} call. Doing so is undefined behavior and may break the internal SDK state. For example:
This method should never be called inside an event handler originating from a previous {{sdk method|wait}} call. Doing so is undefined behavior and may break the internal SDK state. For example:
Line 25: Line 25:
}
}
</C>
</C>
|seealso=
* {{sdk method|event_set}}
}}
}}

Revision as of 00:18, 30 September 2013

Method call snippet vp_wait(instance, 1000);

Pumps incoming and outgoing network traffic and fires any registered events. Required for most in-world method calls (e.g. vp_say()) and events to actually happen.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
int
milliseconds
Maximum amount of time to pump (in milliseconds)

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_NOT_INITIALIZED SDK not initialized with vp_init() yet

Behavior

  • This will attempt to send all pending messages and receive all pending data within the given time limit
  • All SDK events are fired from this method call
  • If a value of 0 is passed, it could still fire a number of different events
  • If there is nothing to handle, it will wait until the time limit. Else, it will return immediately after handling all pending data

Caveats

This method should never be called inside an event handler originating from a previous vp_wait() call. Doing so is undefined behavior and may break the internal SDK state. For example: <C> ... vp_event_set(instance, VP_EVENT_AVATAR_ADD, event_avatar_add); while(vp_wait(instance, 1000) == 0){} ... void event_avatar_add(VPInstance sdk) {

   char message[100];
   sprintf((char*)&message, "Hello, %s!", vp_string(sdk, VP_AVATAR_NAME));
   vp_say(sdk, (char*)&message);
   vp_wait(instance, 1000); // Undefined behavior

} </C>

Examples

This method has no usage examples; please add at least one to this page

See also