コード例 #1
0
//----------------------------------------------------------------------------
void ServerLoop::Run()
{
	double lastReportTimeTime = GetTimeInSeconds();

	int cursaveday = -1;
	while (!mIsShutdownServer)
	{
		double curTime = GetTimeInSeconds();

		if (curTime - lastReportTimeTime > 600.0)
		{
			// 每10分钟向帐号服务器汇报状态

			lastReportTimeTime = curTime;

			// 每天3点保存角色数据

			LocalDateTime time;
			int hour = time.Hour();
			int day = time.Day();
			if (3 == hour && mCurDay != day)
			{
				// save
			}

		}

		System::SleepSeconds(0.1f);
	}

}
コード例 #2
0
ファイル: AstmField.cpp プロジェクト: AlekNS/smitlab-service
//----------------------------------------------------------------------------//
void AstmField::setDate(const LocalDateTime &val, const int &index, const int &repeatedIndex)
{
    char output[18];
    
#if defined(POCO_OS_FAMILY_WINDOWS)
    _snprintf_s(output, 16, "%04d%02d%02d", val.year(), val.month(), val.day());
#else
    snprintf(output, 16, "%04d%02d%02d", val.year(), val.month(), val.day());
#endif
    
    checkIndex(index, repeatedIndex, true);
    _items[index + repeatedIndex * _componentSize] = output;
}
コード例 #3
0
ファイル: DateTimeFormatter.cpp プロジェクト: 119/vdc
void DateTimeFormatter::append(std::string& str, const LocalDateTime& dateTime, const std::string& fmt)
{
	DateTimeFormatter::append(str, dateTime.utc(), fmt, dateTime.tzd());
}
コード例 #4
0
//----------------------------------------------------------------------------
bool ServerLoop::Initlize()
{
	InitializeNetwork();

	time_t ti; time(&ti); srand((unsigned int)ti);

#ifdef PX2_USE_MEMORY
	Memory::Initialize();
#endif

	StringHelp::Initlize();
	FString::Initlize();

	Logger *logger = new0 Logger();

#if defined(_WIN32) || defined(WIN32)
	logger->AddFileHandler("log_server.txt", LT_INFO | LT_ERROR | LT_USER);
#endif
	logger->AddOutputWindowHandler(LT_INFO | LT_ERROR | LT_USER);
	logger->AddConsoleHandler(LT_INFO | LT_ERROR | LT_USER);
	logger->SetLogFileInfo(false);
	logger->StartLogger();

	LocalDateTime time;
	int year1 = time.Year();
	int month1 = time.Month();
	int week1 = time.Week();
	int dayOfMonth1 = time.Day();
	int dayOfWeek1 = time.DayOfWeek();
	int dayOfYear1 = time.DayOfYear();
	int hour1 = time.Hour();
	int minute1 = time.Minute();
	int second1 = time.Second();
	int millisecond1 = time.Millisecond();
	int microsecond1 = time.Microsecond();
	PX2_LOG_INFO("Y:%d; M:%d; W:%d; DayfMonth:%d; DayOfWeek:%d; H:%d; M:%d; S:%d; Milli:%d; MicroS:%d",
		year1, month1, week1, dayOfMonth1, dayOfWeek1, hour1, minute1, second1, millisecond1, microsecond1);

	return true;
}
コード例 #5
0
//----------------------------------------------------------------------------
bool EngineLoop::Initlize()
{
	time_t ti; time(&ti); srand((unsigned int)ti);

#ifdef PX2_USE_MEMORY
	Memory::Initialize();
#endif

	StringHelp::Initlize();
	FString::Initlize();

	Logger *logger = new0 Logger();

#if defined(_WIN32) || defined(WIN32)
	logger->AddFileHandler("PX2Application_Log.txt", LT_INFO | LT_ERROR | LT_USER);
#endif
	logger->AddOutputWindowHandler(LT_INFO | LT_ERROR | LT_USER);
	logger->StartLogger();

	LocalDateTime time;
	int year1 = time.Year();
	int month1 = time.Month();
	int week1 = time.Week();
	int day1 = time.Day();
	int dayOfWeek1 = time.DayOfWeek();
	int dayOfYear1 = time.DayOfYear();
	int hour1 = time.Hour();
	int minute1 = time.Minute();
	int second1 = time.Second();
	int millisecond1 = time.Millisecond();
	int microsecond1 = time.Microsecond();
	PX2_LOG_INFO("Year:%d; Month:%d; Week:%d; Day:%d; DayOfWeek:%d; DayOfYear:%d; Hour:%d; Minute:%d; Second:%d; Millisecond:%d; Microsecond:%d",
		year1, month1, week1, day1, dayOfWeek1, dayOfYear1, hour1, minute1, second1, millisecond1, microsecond1);

	mTimerMan = new0 TimerManager();

	mIMEDisp = new0 IMEDispatcher();

	mInputMan = new0 InputManager();

	mLanguageMan = new0 LanguageManager();
	mResMan = new0 ResourceManager();

	//PX2_LM.Add("Data/engine/engineLanguage.csv");

	mEventWorld = new0 EventWorld();

	mScriptMan = new0 LuaManager();

	mRoot = new0 GraphicsRoot();
	mRoot->Initlize();

	mFontMan = new0 FontManager();
	PX2_UNUSED(mFontMan);

	mADMan = new0 AddDeleteManager();
	PX2_UNUSED(mADMan);

	mSelection = new0 Selection();
	PX2_UNUSED(mSelection);

	mCreater = new0 Creater();
	PX2_UNUSED(mCreater);

	mURDoMan = new0 URDoManager();
	PX2_UNUSED(mURDoMan);

	mAccoutManager = new0 AccoutManager();

	LuaManager *luaMan = (LuaManager*)mScriptMan;
	tolua_PX2_open(luaMan->GetLuaState());

	mScriptMan->SetUserTypePointer("PX2_ENGINELOOP", "EngineLoop", this);
	mScriptMan->SetUserTypePointer("PX2_LOG", "Logger", Logger::GetSingletonPtr());
	mScriptMan->SetUserTypePointer("PX2_LM", "LanguageManager", &(PX2_LM));
	mScriptMan->SetUserTypePointer("PX2_RM", "ResourceManager", ResourceManager::GetSingletonPtr());
	mScriptMan->SetUserTypePointer("PX2_SM", "ScriptManager", ScriptManager::GetSingletonPtr());
	mScriptMan->SetUserTypePointer("PX2_SELECTION", "Selection", Selection::GetSingletonPtr());
	mScriptMan->SetUserTypePointer("PX2_CREATER", "Creater", Creater::GetSingletonPtr());
	mScriptMan->SetUserTypePointer("PX2_URM", "URDoManager", URDoManager::GetSingletonPtr());

	LoadBoost("Data/boost.xml");

	return true;
}
コード例 #6
0
ファイル: LocalDateTime.cpp プロジェクト: 119/vdc
Timespan LocalDateTime::operator - (const LocalDateTime& dateTime) const
{
	return Timespan((utcTime() - dateTime.utcTime())/10);
}
コード例 #7
0
ファイル: LocalDateTime.cpp プロジェクト: 119/vdc
bool LocalDateTime::operator >= (const LocalDateTime& dateTime) const	
{
	return utcTime() >= dateTime.utcTime();
}
コード例 #8
0
ファイル: vlsave.cpp プロジェクト: commshare/live
int main(int argc, char **argv)
{

	if (argc < 3)
	{
		cout << "Uage:" << argv[0] << " [ -f ] <src server > <save file >" << endl;
		exit(0);
	}

	signal(SIGHUP, sigroutine); //* 下面设置三个信号的处理方法
	signal(SIGINT, sigroutine);
	signal(SIGQUIT, sigroutine);

	bool dfps = false;
	int postion = 0;
	if (argc == 4 && (string(argv[1]) == string("-f")))
	{
		postion++;
		dfps = true;
	}

	NetH264Reader reader(argv[postion + 1]);
	FILE *out;

	cout << "connect server " << argv[postion + 1] << endl;
	if (reader.open())
	{
		cout << "connect server " << argv[postion + 1] << " sucess" << endl;
		out = fopen(argv[postion + 2], "wb");
		if (out)
		{

			H264NALU *nalu = 0;
			char naluHead[] =
			{ 0x0, 0x0, 0x0, 0x1 };
			int time = LocalDateTime().second();
			int fps = 0;
			while (run)
			{
				nalu = reader.readH264();
				if (nalu != 0)
				{
					if (dfps)
					{
						if (LocalDateTime().second() == time)
						{
							fps++;
						}
						else
						{
							LocalDateTime ld;
							cout << ld.year() << "-" << ld.month() << "-" << ld.day() << " " << ld.hour() << ":" << ld.minute() << ":" << ld.second() << " recevie fps:" << fps
									<< endl;
							fps = 1;
							time = LocalDateTime().second();
						}
					}
					fwrite(naluHead, 4, 1, out);
					fwrite(nalu->getData(), nalu->getLength(), 1, out);
				}
				else
				{
					cout << "disconnet server " << endl;
					break;
				}

			}
			
			fclose(out);
			out = NULL;
		}
		else
		{
			cout << "open file " << argv[postion + 2] << " error" << endl;
		}
	}
	else
	{
		cout << "connect server " << argv[postion + 1] << " fail" << endl;
	}

}