Function Call
Once registered, cloud code function can be called from the client.
Source Code
using PlayNANOO;
using PlayNANOO.CloudCode;
using PlayNANOO.SimpleJSON;
public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;
void Awake()
{
plugin = Plugin.GetInstance();
var parameters = new CloudCodeExecution()
{
TableCode = "CLOUDCODE_TALBLE_CODE",
FunctionName = "CLOUDCODE_FUNCTION_NAME",
FunctionArguments = new {
inputValue1 = "inputValue1",
inputValue2 = "inputValue2",
}
};
plugin.CloudCode.Run(parameters, (state, message, rawData, dictionary) =>
{
if (state.Equals(Configure.PN_API_STATE_SUCCESS))
{
PlayNANOO.SimpleJSON.JSONNode node = PlayNANOO.SimpleJSON.JSONNode.Parse(dictionary["Result"].ToString());
Debug.Log(node["Function"]["Name"].Value);
Debug.Log(node["Function"]["Version"].Value);
}
else
{
Debug.Log("Fail");
}
});
}
}
Call Information Details
Parameter | Description | Type |
---|---|---|
TableCode | Table Code | string |
FunctionName | Function name in the cloud code | string |
FunctionArguments | Data to be sent to cloud code function | Anonymous |
FunctionArguments can only send String data.
Communication Result
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"Function": Object,
"Logs": Array,
"Result": Object,
"Error": Object,
"RunTimeMilliSeconds": Integer
}
Communication Result Details
Data Key | Description | Type |
---|---|---|
Function | Cloud code debug information | object |
Logs | Cloud code debug information | array |
Result | Cloud code function call result | object |
Error | Error information from cloud code | object |
RunTimeMilliSeconds | Run time of cloud code call in milliseconds | integer |