Skip to main content

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

ParameterDescriptionType
TableCodeTable Codestring
FunctionNameFunction name in the cloud codestring
FunctionArgumentsData to be sent to cloud code functionAnonymous

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 KeyDescriptionType
FunctionCloud code debug informationobject
LogsCloud code debug informationarray
ResultCloud code function call resultobject
ErrorError information from cloud codeobject
RunTimeMilliSecondsRun time of cloud code call in millisecondsinteger