函数调用
云代码的函数注册完成后,可以从客户端调用该函数。
源代码
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 |
FunctionArguments 只能发送 String 类型的数据。
通信结果
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 |