跳转到主要内容

函数调用

云代码的函数注册完成后,可以从客户端调用该函数。

源代码

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");
}
});
}
}

调用详细信息

参数说明类型
TableCode表代码string
FunctionName在云代码中编写的函数名string
FunctionArguments要传递给云代码函数的数据Anonymous

通信结果

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

通信结果详细信息

数据键说明类型
Function云代码调用函数信息object
Logs云代码调试信息array
Result云代码调用结果object
Error云代码错误信息object
RunTimeMilliSeconds云代码调用耗时integer