示例#1
0
文件: main.cpp 项目: imane-jym/gp
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;
}
示例#2
0
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");
}