Skip to main content

Function Call

Once the cloud code function registration is complete, you can call the function 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 Details

ParameterDescriptionType
TableCodeTable codestring
FunctionNameFunction name written in cloud codestring
FunctionArgumentsData to pass to the cloud code functionAnonymous

Response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"Function": Object,
"Logs": Array,
"Result": Object,
"Error": Object,
"RunTimeMilliSeconds": Integer
}

Response Details

Data KeyDescriptionType
FunctionCloud code called function informationobject
LogsCloud code debug informationarray
ResultCloud code call resultobject
ErrorCloud code error informationobject
RunTimeMilliSecondsCloud code call elapsed timeinteger