static int StartServer(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); GConsoleCore obj = (GConsoleCore)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GConsoleCore"); obj.StartServer(); return(0); }
static int Echo(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 2); GConsoleCore obj = (GConsoleCore)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GConsoleCore"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); obj.Echo(arg0); return(0); }
static int StartClient(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 3); GConsoleCore obj = (GConsoleCore)LuaScriptMgr.GetUnityObjectSelf(L, 1, "GConsoleCore"); string arg0 = LuaScriptMgr.GetLuaString(L, 2); int arg1 = (int)LuaScriptMgr.GetNumber(L, 3); obj.StartClient(arg0, arg1); return(0); }
void Awake() { instance = this; ///只有server可以记录,因为console把callback注册到ui了,除非改写GConsole的HandleUnityLog,才能写到文件去 if (isServer) { if (isLogFile) { FileStream fs = null; if (isAppendFile) { fs = File.Open(System.IO.Path.Combine(Application.persistentDataPath, "log.txt"), FileMode.Append, FileAccess.Write, FileShare.Read); } else { fs = File.Open(System.IO.Path.Combine(Application.persistentDataPath, "log.txt"), FileMode.Create, FileAccess.Write, FileShare.Read); } logWriter = new StreamWriter(fs); } Application.RegisterLogCallback(LogCallback); } }
static int get_port(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsoleCore obj = (GConsoleCore)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name port"); } else { LuaDLL.luaL_error(L, "attempt to index port on a nil value"); } } LuaScriptMgr.Push(L, obj.port); return(1); }
static int set_isServer(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsoleCore obj = (GConsoleCore)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name isServer"); } else { LuaDLL.luaL_error(L, "attempt to index isServer on a nil value"); } } obj.isServer = LuaScriptMgr.GetBoolean(L, 3); return(0); }
static int set_act(IntPtr L) { object o = LuaScriptMgr.GetLuaObject(L, 1); GConsoleCore obj = (GConsoleCore)o; if (obj == null) { LuaTypes types = LuaDLL.lua_type(L, 1); if (types == LuaTypes.LUA_TTABLE) { LuaDLL.luaL_error(L, "unknown member name act"); } else { LuaDLL.luaL_error(L, "attempt to index act on a nil value"); } } LuaTypes funcType = LuaDLL.lua_type(L, 3); if (funcType != LuaTypes.LUA_TFUNCTION) { obj.act = (Action <string>)LuaScriptMgr.GetNetObject(L, 3, typeof(Action <string>)); } else { LuaFunction func = LuaScriptMgr.ToLuaFunction(L, 3); obj.act = (param0) => { int top = func.BeginPCall(); LuaScriptMgr.Push(L, param0); func.PCall(top, 1); func.EndPCall(top); }; } return(0); }