示例#1
0
文件: Test.cs 项目: aivclab/pyunirpc
        private void TestResult()
        {
            string json =
                @"{'rpc_tag': '__RPC_RESULT__', 
                'handle': 'testfun', 
                'uid': 666, 
                'result': 
                    ['some string', 
                        {'rpc_tag': '__RPC_VAL_NDARRAY__', 
                        'dtype': 'int64', 
                        'shape': [3], 
                        'data': 'BgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAA'}
                    ]
                }";

            PyUniResult call = PyUniType.JsonConstructor <PyUniResult>(json) as PyUniResult;

            string newjson = call.PackJSON();

            print(newjson);
        }
示例#2
0
文件: Test.cs 项目: aivclab/pyunirpc
        private void TestCall()
        {
            string json =
                @"{'rpc_tag': '__RPC_CALL__', 
                'handle': 'testfun', 
                'uid': 666, 
                'args': ['lul', 'wut'],
                'kwargs':
                    {'some string': 
                        {'rpc_tag': '__RPC_VAL_NDARRAY__', 
                        'dtype': 'int64', 
                        'shape': [3], 
                        'data': 'BgAAAAAAAAAHAAAAAAAAAAgAAAAAAAAA'}
                    }
                }";

            PyUniCall call = PyUniType.JsonConstructor <PyUniCall>(json) as PyUniCall;

            string newjson = call.PackJSON();

            print(newjson);
        }
示例#3
0
文件: Test.cs 项目: aivclab/pyunirpc
        private void TestError()
        {
            string json =
                @"{'rpc_tag': '__RPC_ERROR__', 
                'handle': 'testfun', 
                'uid': 666, 
                'exception': 'ValueError',
                'descr' : 'whoops'
                }";

            var result = PyUniType.JsonConstructor <PyUniResult>(json);

            try
            {
                var res = result as PyUniResult;
                Debug.Log(res.result[0]);
            }
            catch (Exception)
            {
                var err = result as PyUniError;
                Debug.LogError($"{err.exception}: {err.descr}");
            }
        }