bool InitServer() { srand(time(NULL)); //日志等级 INISection * configPath = g_serverIni.GetSection("config"); if (!configPath) { IME_ERROR("Miss section [config] in config ini"); return false; } std::string strLogLevel; if (!configPath->ReadString("loglevel",strLogLevel)) { IME_ERROR("Missing loglevel info"); return false; } sLog->SetLogLevel((char *)strLogLevel.c_str()); int debugmask = 0; if (!configPath->ReadInt("logdebug", debugmask)) { IME_ERROR("Missing logdebug"); return false; } IME_LOG("log debug %x", (unsigned int)debugmask); sLog->SetDebugLogMask((DebugLogFilters)debugmask); ////////////////////////////////////////////////////////////////////////// #ifdef LUA_USE_VERSION sSCript->Init(CScriptSupport::LUA_SCRIPT); sSCript->LoadScript(CSet::ScriptMainFile); #elif defined JAVASCRIPT_uSE_VERSION #endif if (!HandlerInit(MAIN_THREAD)) { IME_ERROR("man thread handler init fail"); return false; } //////// // if (!g_luaState.Init()) // { // IME_ERROR("luaState Init failed."); // return false; // } // //tolua_LuaExport_open(g_luaState.GetState()); // // if (!CLuaCtrl::Init()) // { // IME_ERROR("CLuaCtrl init error"); // return false; // } return true; }
void CNetRunnable::run() { INISection * server = g_serverIni.GetSection("server"); if (!server) { IME_ERROR("Miss section [server] in ***server.ini"); return ; } int nPort = 0; if (!server->ReadInt("listen_port",nPort)) { IME_ERROR("Miss listen_port"); return ; } IME_LOG("NetRunnable thread start!"); m_server.Init(); if (!m_server.StartServer("",nPort)) { g_stopEvent = true; } IME_LOG("NetRunnable thread exit"); }
///Runs the benchmark bool Benchmark() { INIFile ini; if(!ini.OpenFile(BenchFile)) return false; while(ini.Next()) { CurrentSection = ini.GetSection(ini.GetSection("")->GetName()); switch(Type) { case BT_STRING: case BT_STRINGRULES: if(!STL) BenchRead<const char * const, const char *>(&INISection::ReadString); #ifndef MINIINI_NO_STL else BenchRead<const std::string &, std::string>(&INISection::ReadString); #endif break; case BT_INT: if(!STL) BenchRead<const char * const, int>(&INISection::ReadInt); #ifndef MINIINI_NO_STL else BenchRead<const std::string &, int>(&INISection::ReadInt); #endif break; case BT_FLOAT: if(!STL) BenchRead<const char * const, float>(&INISection::ReadFloat); #ifndef MINIINI_NO_STL else BenchRead<const std::string &, float>(&INISection::ReadFloat); #endif break; case BT_BOOL: if(!STL) BenchRead<const char * const, bool>(&INISection::ReadBool); #ifndef MINIINI_NO_STL else BenchRead<const std::string &, bool>(&INISection::ReadBool); #endif break; case BT_MULTISTRING: BENCHREADMULTI(ReadMultiString, const char *, std::string); break; case BT_MULTIINT: BENCHREADMULTI(ReadMultiInt, int, int); break; case BT_MULTIFLOAT: BENCHREADMULTI(ReadMultiFloat, float, float); break; case BT_MULTIBOOL: BENCHREADMULTI(ReadMultiBool, bool, bool); break; case BT_STRINGS: BENCHREADARRAY(ReadStrings, const char *, std::string); break; case BT_INTS: BENCHREADARRAY(ReadInts, int, int); break; case BT_FLOATS: BENCHREADARRAY(ReadFloats, float, float); case BT_BOOLS: BENCHREADARRAY(ReadBools, bool, bool); break; default: return false; break; } } #ifdef MINIINI_BENCH_EXTRA #ifdef linux FileTime = miniini_private::bench_filetime; AllocTime = miniini_private::bench_alloctime; LoadTime = miniini_private::bench_loadtime; #endif #endif return true; }