callRemote
Client-side
Server-side
Shared
Manual Review Required
Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.
This function allows you to call functions that have been exported with HTTP access by other MTA servers. The calls are asynchronous so you do not get an immediate result from the call, instead a callback function you specify is called when the call returns.
Syntax
bool callRemote ( string host, string resourceName, string functionName, callback callbackFunction, unknown arguments..., [ string queueName = "default", int connectionAttempts = 10, int connectTimeout = 10000 ] )Required Arguments
- host: This is a host name - including the HTTP port - of the server you wish to connect to.
- resourceName: This is a name of the resource that contains the exported function you want to call.
- functionName: This is a string with the name of the function which you want to call.
- callbackFunction: This is the function that should receive the data returned from the remote function call. The argument list should match the format of the data returned. The callback function will be passed a string containing "ERROR" followed by an integer indicating the error code when an error occurs calling the function. A list of error codes can be found here .
- arguments...: MISSING_PARAM_DESC
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- queueName (default: "default"): MISSING_PARAM_DESC
- connectionAttempts (default: 10): Number of times to retry if the remote host does not respond. In the case of a non-responding remote server, each connection attempt will timeout after 6 seconds. Therefore, the default setting of 10 connection attempts means it will be 60 seconds before your script gets a callback about the error. Reducing this value to 2 for example, will decrease that period to 12 seconds
- connectTimeout (default: 10000): Number of milliseconds each connection attempt will take before timing out
Returns
- bool: value
Returns true if the function has been called, false otherwise.
Code Examples
shared
PHP:(for the page that Lua expects to be athttp://www.example.com/page.php)
[php]include( "mta_sdk.php" );$input = mta::getInput();mta::doReturn($input[0] + $input[1]);See Also
Resource Functions
- abortRemoteRequest
- addResourceConfig
- addResourceMap
- call
- callRemote
- copyResource
- createResource
- deleteResource
- fetchRemote
- getRemoteRequestInfo
- getRemoteRequests
- getResourceACLRequests
- getResourceConfig
- getResourceDynamicElementRoot
- getResourceExportedFunctions
- getResourceFromName
- getResourceGUIElement
- getResourceInfo
- getResourceLastStartTime
- getResourceLoadFailureReason
- getResourceLoadTime
- getResourceMapRootElement
- getResourceName
- getResourceOrganizationalPath
- getResourceRootElement
- getResources
- getResourceState
- getThisResource
- isResourceArchived
- isResourceProtected
- refreshResources
- removeResourceFile
- renameResource
- restartResource
- setResourceInfo
- startResource
- stopResource
- updateResourceACLRequest