|
2019独角兽企业重金招聘Python工程师标准>>>
CS代码- lua = new LuaState();
- lua.AddSearchPath(Application.dataPath + "/Lua");
- lua.AddSearchPath(Application.dataPath + "/ToLua/Lua");
- lua.AddSearchPath(Application.dataPath + "/ToLua");
- lua.Start();
- LuaBinder.Bind(lua);
- lua.BeginModule(null);
- lua.BeginModule("RpcClient");
- lua.RegFunction("SendRequest", (System.IntPtr l) =>
- {
- string service = LuaDLL.lua_tostring(l, 1);
- string method = LuaDLL.lua_tostring(l, 2);
- string para = LuaDLL.lua_tostring(l, 3);
- LuaTypes t = LuaDLL.lua_type(l, 4);
- LuaFunction func = null; // 要先保存下来
- if (t == LuaTypes.LUA_TFUNCTION)
- {
- func = ToLua.ToLuaFunction(l, 4);
- }
- else
- {
- Debug.LogWarning("[LUA]:cb not a function");
- }
- RpcClient.ins.SendRequest( service,method,para, (string msg) =>
- {
- func.BeginPCall();
- func.Push(msg);
- func.PCall();
- func.EndPCall();
- });
-
- return 0;
- });
- lua.EndModule();
- lua.EndModule();
- lua.DoFile("Main.lua");
复制代码 LUA代码- --主入口函数。从这里开始lua逻辑
- RpcClient.SendRequest("services.login", "login", "account:1,pwd:1,",function (msg)
-
- print(msg)
- end);
复制代码
转载于:https://my.oschina.net/kkkkkkkkkkkkk/blog/842049 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|