RestartResource: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Server function}} | {{Server function}} | ||
__NOTOC__ | __NOTOC__ | ||
This function restarts a running resource. | This function restarts a running resource. Restarting will destroy all the elements that the resource has created (as stopping the resource does). | ||
'''Note:''' This function does not restart the resource immediately. Restarts are queued up until the end of the server's frame to ensure that they occur in the correct order (and that dependent resources can start and stop correctly). The resource being restarted will have an [[onResourceStop]] event triggered and the restarted instance will receive an [[onResourceStart]] event. Remember that the element and resource variables will be invalidated during the restart, though of course, the resource's name will not. | '''Note:''' This function does not restart the resource immediately. Restarts are queued up until the end of the server's frame to ensure that they occur in the correct order (and that dependent resources can start and stop correctly). The resource being restarted will have an [[onResourceStop]] event triggered and the restarted instance will receive an [[onResourceStart]] event. Remember that the element and resource variables will be invalidated during the restart, though of course, the resource's name will not. | ||
Revision as of 23:00, 13 April 2008
This function restarts a running resource. Restarting will destroy all the elements that the resource has created (as stopping the resource does).
Note: This function does not restart the resource immediately. Restarts are queued up until the end of the server's frame to ensure that they occur in the correct order (and that dependent resources can start and stop correctly). The resource being restarted will have an onResourceStop event triggered and the restarted instance will receive an onResourceStart event. Remember that the element and resource variables will be invalidated during the restart, though of course, the resource's name will not.
Syntax
bool restartResource ( resource theResource )
Required Arguments
- theResource: the resource you want to restart.
Returns
Returns true if the resource was restarted, false if the restart failed, or an invalid resource was passed.
Example
This function restarts all running resources.
function restartAllResources() -- we store a table of resources local allResources = getResources() -- for each one of them, for index, res in ipairs(allResources) do -- if it's running, if getResourceState(res) == "running" then -- then restart it restartResource(res) end end end
See Also
- abortRemoteRequest
- call
- fetchRemote
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceName
- getResourceRootElement
- getResourceState
- getThisResource
- getRemoteRequests
- getRemoteRequestInfo