Пример #1
0
void processCommandLineOptions( int argc, char* argv[] )
{
	int iargs = 1;
	authenticationToken.clear();
	newauthenticationToken.clear();
	authenticationExtended.clear();

	while ( iargs < argc )
	{
		if ( 0 == strcmp( "-?", argv[iargs] ) )
		{
			printUsage();
		}
		else if ( strcmp( "-at", argv[iargs] ) == 0 )
		{
			++iargs; if ( iargs == argc ) printUsage();

			authenticationToken.set(argv[iargs++]);
		}
		else if ( strcmp( "-newat", argv[iargs] ) == 0 )
		{
			++iargs; if ( iargs == argc ) printUsage();

			newauthenticationToken.set(argv[iargs++]);
		}
		else if ( strcmp( "-aid", argv[iargs] ) == 0 )
		{
			++iargs; if ( iargs == argc ) printUsage();

			appId.set(argv[iargs++]);
		}
		else if (strcmp("-ax", argv[iargs]) == 0)
		{
			++iargs; if (iargs == argc) printUsage();

			authenticationExtended.set(argv[iargs++]);
		}
		else
		{
			cout << "Invalid argument: " << argv[iargs] << endl;

			printUsage();
		}

		if (authenticationToken.empty())
		{
			cout << "Missing Authentication Token." << endl;

			printUsage();
		}
	}
}
Пример #2
0
int main( int argc, char* argv[] )
{
	try {
		authenticationToken.clear();
		newauthenticationToken.clear();
		authenticationExtended.clear();
		processCommandLineOptions( argc, argv );
		printActiveConfig();
		AppLoginClient loginClient;

		EmaBuffer authnExtendedBuf;

		Login::LoginReq loginMsg;

		OmmConsumerConfig consumerConfig;

		loginMsg.name(authenticationToken).applicationId(appId).nameType(USER_AUTH_TOKEN);
		if (!authenticationExtended.empty())
		{
			authnExtendedBuf.setFrom(authenticationExtended.c_str(), authenticationExtended.length());
			loginMsg.authenticationExtended(authnExtendedBuf);
		}
			
		
		consumerConfig.addAdminMsg(loginMsg.getMessage());

		AppClient appClient;
		OmmConsumer consumer( consumerConfig, loginClient);
		
		
		consumer.registerClient( ReqMsg().serviceName( "DIRECT_FEED" ).name( "TRI.N" ), appClient );
		
		for (int i = 0; i < 60; i++)
		{
			
			if (loginClient._TTReissue != 0 && getCurrentTime() >= loginClient._TTReissue)
			{
				loginMsg.clear().name(authenticationToken).applicationId(appId).nameType(USER_AUTH_TOKEN);
				if (!authenticationExtended.empty())
				{
					loginMsg.authenticationExtended(authnExtendedBuf);
				}

				consumer.reissue(loginMsg.getMessage(), loginClient._handle);
				loginClient._TTReissue = 0;
			}
			
			sleep(1000);
			if ( i == 3 )
			{
				cout << endl << "SEND PAUSE USING first TOKEN" << endl;
					loginMsg.clear().name(authenticationToken).applicationId(appId).nameType(USER_AUTH_TOKEN).pause(true);
				consumer.reissue(loginMsg.getMessage(), loginClient._handle);
			}
			if ( i == 10 )
			{
				cout << endl << "Renew new TOKEN with PAUSE falg" << endl;
					loginMsg.clear().name(newauthenticationToken).applicationId(appId).nameType(USER_AUTH_TOKEN).pause(true);
				consumer.reissue(loginMsg.getMessage(), loginClient._handle);
			}
			if ( i == 13 )
			{
				cout << endl << "SEND RESUME USING second TOKEN" << endl;
					loginMsg.clear().name(newauthenticationToken).applicationId(appId).nameType(USER_AUTH_TOKEN).pause(false);
				consumer.reissue(loginMsg.getMessage(), loginClient._handle);
			}
		}

	}
	catch ( const OmmException& excp ) {
		cout << excp << endl;
	}
	return 0;
}