Ejemplo n.º 1
0
void OmmArrayEncoder::addAscii( const EmaString& value )
{
	if ( !_rsslArray.primitiveType )
	{
		_rsslArray.primitiveType = RSSL_DT_ASCII_STRING;

		acquireEncIterator();

		initEncode();
	}
	else if ( _rsslArray.primitiveType != RSSL_DT_ASCII_STRING )
	{
		EmaString temp( "Attempt to addAscii() while OmmArray contains='" );
		temp.append( getDTypeAsString( dataType[ _rsslArray.primitiveType ] ) ).append( "'. " );
		throwIueException( temp );
		return;
	}

	if ( _rsslArray.itemLength && _rsslArray.itemLength < value.length() )
	{
		EmaString temp( "Passed in value is longer than fixed width in addAscii(). Fixed width='" );
		temp.append( _rsslArray.itemLength ).append( "'. " );
		throwIueException( temp );
		return;
	}

	RsslBuffer buffer;
	buffer.data = (char*)value.c_str();
	buffer.length = value.length();

	addPrimitiveEntry( "addAscii()", &buffer );
}
Ejemplo n.º 2
0
void MapEncoder::addKeyAscii(const EmaString& key, MapEntry::MapAction action,
	const EmaBuffer& permissionData)
{
	validateEntryKeyAndPayLoad(RSSL_DT_ASCII_STRING, RSSL_DT_NO_DATA, DataType::NoDataEnum, "addKeyAscii()");

	RsslBuffer buffer;
	buffer.data = (char*)key.c_str();
	buffer.length = key.length();

	addEntryWithNoPayload(&buffer, action, permissionData, "addKeyAscii()");
}
Ejemplo n.º 3
0
void MapEncoder::addKeyState(OmmState::StreamState streamState, OmmState::DataState dataState, UInt8 statusCode, const EmaString& statusText,
	MapEntry::MapAction action, const EmaBuffer& permissionData)
{
	validateEntryKeyAndPayLoad(RSSL_DT_STATE, RSSL_DT_NO_DATA, DataType::NoDataEnum, "addKeyState()");

	RsslState state;
	state.streamState = streamState;
	state.dataState = dataState;
	state.code = statusCode;
	state.text.data = (char*)statusText.c_str();
	state.text.length = statusText.length();

	addEntryWithNoPayload(&state, action, permissionData, "addKeyState()");
}
Ejemplo n.º 4
0
void AckMsgEncoder::text( const EmaString& text )
{
    acquireEncIterator();

#ifdef __EMA_COPY_ON_SET__
    _text = text;
    _rsslAckMsg.text.data = (char*)_text.c_str();
    _rsslAckMsg.text.length = _text.length();
#else
    _rsslAckMsg.text.data = (char*)text.c_str();
    _rsslAckMsg.text.length = text.length();
#endif

    rsslAckMsgApplyHasText( &_rsslAckMsg );
}
Ejemplo n.º 5
0
void ReqMsgEncoder::name( const EmaString& name )
{
	acquireEncIterator();

#ifdef __EMA_COPY_ON_SET__
	_name = name;
	_rsslRequestMsg.msgBase.msgKey.name.data = (char*)_name.c_str();
	_rsslRequestMsg.msgBase.msgKey.name.length = _name.length();
#else
	_rsslRequestMsg.msgBase.msgKey.name.data = (char*)name.c_str();
	_rsslRequestMsg.msgBase.msgKey.name.length = name.length();
#endif

	_rsslRequestMsg.msgBase.msgKey.flags |= RSSL_MKF_HAS_NAME;
}
Ejemplo n.º 6
0
void MapEncoder::addKeyState( OmmState::StreamState streamState, OmmState::DataState dataState, UInt8 statusCode, const EmaString& statusText,
	MapEntry::MapAction action, const ComplexType& value, const EmaBuffer& permissionData )
{
	const Encoder& enc = value.getEncoder();

	UInt8 rsslDataType = enc.convertDataType( value.getDataType() );

	validateEntryKeyAndPayLoad(RSSL_DT_STATE, rsslDataType, value.getDataType(), "addKeyState()");

	RsslState state;
	state.streamState = streamState;
	state.dataState = dataState;
	state.code = statusCode;
	state.text.data = (char*)statusText.c_str();
	state.text.length = statusText.length();

	if ( action == MapEntry::DeleteEnum )
	{
		addEntryWithNoPayload( &state, action, permissionData, "addKeyState()" );
	}
	else if ( value.hasEncoder() && enc.ownsIterator() )
	{
		if ( enc.isComplete() )
			addEncodedEntry( &state, action, value, permissionData, "addKeyState()" );
		else
		{
			EmaString temp( "Attempt to add a ComplexType while complete() was not called on this ComplexType." );
			throwIueException( temp );
			return;
		}
	}
	else if ( value.hasDecoder() )
	{
		addDecodedEntry( &state, action, value, permissionData, "addKeyState()" );
	}
	else
	{
		if ( rsslDataType == RSSL_DT_MSG )
		{
			EmaString temp( "Attempt to pass in an empty message while it is not supported." );
			throwIueException( temp );
			return;
		}

		passEncIterator( const_cast<Encoder&>( enc ) );
		startEncodingEntry( &state, action, permissionData, "addKeyState()" );
	}
}
Ejemplo n.º 7
0
void FieldListEncoder::addAscii( Int16 fieldId, const EmaString& value )	
{
	if ( rsslFieldListCheckHasStandardData( &_rsslFieldList ) == RSSL_FALSE )
	{
		rsslFieldListApplyHasStandardData( &_rsslFieldList );

		acquireEncIterator();

		initEncode();
	}

	RsslBuffer buffer;
	buffer.data = (char*)value.c_str();
	buffer.length = value.length();

	addPrimitiveEntry( fieldId, RSSL_DT_ASCII_STRING, "addAscii()", &buffer );
}
Ejemplo n.º 8
0
void MapEncoder::addKeyAscii( const EmaString& key, MapEntry::MapAction action,
	const ComplexType& value, const EmaBuffer& permissionData )
{
	const Encoder& enc = value.getEncoder();

	UInt8 rsslDataType = enc.convertDataType( value.getDataType() );

	validateEntryKeyAndPayLoad(RSSL_DT_ASCII_STRING, rsslDataType, value.getDataType(), "addKeyAscii()");

	RsslBuffer buffer;
	buffer.data = (char*)key.c_str();
	buffer.length = key.length();

	if ( action == MapEntry::DeleteEnum )
	{
		addEntryWithNoPayload( &buffer, action, permissionData, "addKeyAscii()" );
	}
	else if ( value.hasEncoder() && enc.ownsIterator() )
	{
		if ( enc.isComplete() )
			addEncodedEntry( &buffer, action, value, permissionData, "addKeyAscii()" );
		else
		{
			EmaString temp( "Attempt to add a ComplexType while complete() was not called on this ComplexType." );
			throwIueException( temp );
			return;
		}
	}
	else if ( value.hasDecoder() )
	{
		addDecodedEntry( &buffer, action, value, permissionData, "addKeyAscii()" );
	}
	else
	{
		if ( rsslDataType == RSSL_DT_MSG )
		{
			EmaString temp( "Attempt to pass in an empty message while it is not supported." );
			throwIueException( temp );
			return;
		}

		passEncIterator( const_cast<Encoder&>( enc ) );
		startEncodingEntry( &buffer, action, permissionData, "addKeyAscii()" );
	}
}
Ejemplo n.º 9
0
void OmmArrayEncoder::addState( OmmState::StreamState streamState,
				OmmState::DataState dataState,
				UInt8 statusCode,
				const EmaString& statusText )
{
	if ( !_rsslArray.primitiveType )
	{
		if ( _rsslArray.itemLength )
		{
			EmaString temp( "Unsupported fixedWidth encoding in addState(). Fixed width='" );
			temp.append( _rsslArray.itemLength ).append( "'. " );
			throwIueException( temp );
			return;
		}

		_rsslArray.primitiveType = RSSL_DT_STATE;

		acquireEncIterator();

		initEncode();
	}
	else if ( _rsslArray.primitiveType != RSSL_DT_STATE )
	{
		EmaString temp( "Attempt to addState() while OmmArray contains='" );
		temp.append( getDTypeAsString( dataType[ _rsslArray.primitiveType ] ) ).append( "'. " );
		throwIueException( temp );
		return;
	}

	RsslState state;
	state.streamState = streamState;
	state.dataState = dataState;
	state.code = statusCode;
	state.text.data = (char*)statusText.c_str();
	state.text.length = statusText.length();

	addPrimitiveEntry( "addState()", &state );
}
Ejemplo n.º 10
0
void FieldListEncoder::addState( Int16 fieldId,
					OmmState::StreamState streamState,
					OmmState::DataState dataState,
					UInt8 statusCode,
					const EmaString& statusText )
{
	if ( rsslFieldListCheckHasStandardData( &_rsslFieldList ) == RSSL_FALSE )
	{
		rsslFieldListApplyHasStandardData( &_rsslFieldList );

		acquireEncIterator();

		initEncode();
	}

	RsslState state;
	state.streamState = streamState;
	state.dataState = dataState;
	state.code = statusCode;
	state.text.data = (char*)statusText.c_str();
	state.text.length = statusText.length();

	addPrimitiveEntry( fieldId, RSSL_DT_STATE, "addState()", &state );
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 12
0
void LoginHandler::sendLoginReject(RsslReactorChannel* reactorChannel, RsslInt32 streamId, RsslStateCodes stateCode, EmaString& stateText)
{
	ClientSession* clientSession = (ClientSession*)reactorChannel->userSpecPtr;

	rsslClearRDMLoginStatus(&_rsslRdmLoginMsg.status);
	_rsslRdmLoginMsg.status.flags |= RDM_LG_STF_HAS_STATE;
	_rsslRdmLoginMsg.status.rdmMsgBase.streamId = streamId;
	_rsslRdmLoginMsg.status.state.streamState = RSSL_STREAM_CLOSED_RECOVER;
	_rsslRdmLoginMsg.status.state.dataState = RSSL_DATA_SUSPECT;
	_rsslRdmLoginMsg.status.state.code = stateCode;
	_rsslRdmLoginMsg.status.state.text.data = (char*)stateText.c_str();
	_rsslRdmLoginMsg.status.state.text.length = stateText.length();

	rsslClearEncodeIterator(&_rsslEncodeIter);

	if (RSSL_RET_SUCCESS != rsslSetEncodeIteratorRWFVersion(&_rsslEncodeIter, RSSL_RWF_MAJOR_VERSION, RSSL_RWF_MINOR_VERSION))
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error. Failed to set encode iterator version in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	RsslBuffer rsslBuffer;
	rsslBuffer.data = _rsslMsgBuffer.data;
	rsslBuffer.length = _rsslMsgBuffer.length;

	if (RSSL_RET_SUCCESS != rsslSetEncodeIteratorBuffer(&_rsslEncodeIter, &rsslBuffer))
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error. Failed to set encode iterator buffer in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	RsslErrorInfo rsslErrorInfo;
	RsslRet retCode;
	retCode = rsslEncodeRDMLoginMsg(&_rsslEncodeIter, (RsslRDMLoginMsg*)&_rsslRdmLoginMsg.status, &rsslBuffer.length, &rsslErrorInfo);

	while (retCode == RSSL_RET_BUFFER_TOO_SMALL)
	{
		free(rsslBuffer.data);

		_rsslMsgBuffer.length += _rsslMsgBuffer.length;
		_rsslMsgBuffer.data = (char*)malloc(sizeof(char) * _rsslMsgBuffer.length);

		if (!_rsslMsgBuffer.data)
		{
			if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Failed to allocate memory in LoginHandler::sendLoginReject()");
				temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

				_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
			}

			return;
		}

		rsslBuffer.data = _rsslMsgBuffer.data;
		rsslBuffer.length = _rsslMsgBuffer.length;

		clearRsslErrorInfo(&rsslErrorInfo);
		retCode = rsslEncodeRDMLoginMsg(&_rsslEncodeIter, (RsslRDMLoginMsg*)&_rsslRdmLoginMsg, &rsslBuffer.length, &rsslErrorInfo);
	}

	if (retCode != RSSL_RET_SUCCESS)
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error: failed to encode RsslRDMDirectoryMsg in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName()).append(CR)
				.append("Error Id ").append(rsslErrorInfo.rsslError.rsslErrorId).append(CR)
				.append("Internal sysError ").append(rsslErrorInfo.rsslError.sysError).append(CR)
				.append("Error Location ").append(rsslErrorInfo.errorLocation).append(CR)
				.append("Error Text ").append(rsslErrorInfo.rsslError.text);

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	rsslClearDecodeIterator(&_rsslDecodeIter);

	if (rsslSetDecodeIteratorRWFVersion(&_rsslDecodeIter, RSSL_RWF_MAJOR_VERSION, RSSL_RWF_MINOR_VERSION) != RSSL_RET_SUCCESS)
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("IInternal error. Failed to set decode iterator version in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	if (rsslSetDecodeIteratorBuffer(&_rsslDecodeIter, &rsslBuffer) != RSSL_RET_SUCCESS)
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error. Failed to set decode iterator buffer in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	RsslStatusMsg rsslStatusMsg;
	rsslClearStatusMsg(&rsslStatusMsg);
	if (rsslDecodeMsg(&_rsslDecodeIter, (RsslMsg*)&rsslStatusMsg) != RSSL_RET_SUCCESS)
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error. Failed to decode message in LoginHandler::sendLoginReject()");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName());

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}

	rsslStatusMsg.msgBase.streamId = streamId;

	RsslReactorSubmitMsgOptions submitMsgOpts;
	rsslClearReactorSubmitMsgOptions(&submitMsgOpts);

	submitMsgOpts.pRsslMsg = (RsslMsg*)&rsslStatusMsg;

	clearRsslErrorInfo(&rsslErrorInfo);
	if (rsslReactorSubmitMsg(_pOmmServerBaseImpl->getRsslReactor(), reactorChannel, &submitMsgOpts, &rsslErrorInfo) != RSSL_RET_SUCCESS)
	{
		if (OmmLoggerClient::ErrorEnum >= _pOmmServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			EmaString temp("Internal error: rsslReactorSubmitMsg() failed in LoginHandler::sendLoginReject().");
			temp.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(_pOmmServerBaseImpl->getInstanceName()).append(CR)
				.append("Error Id ").append(rsslErrorInfo.rsslError.rsslErrorId).append(CR)
				.append("Internal sysError ").append(rsslErrorInfo.rsslError.sysError).append(CR)
				.append("Error Location ").append(rsslErrorInfo.errorLocation).append(CR)
				.append("Error Text ").append(rsslErrorInfo.rsslError.text);

			_pOmmServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::ErrorEnum, temp);
		}

		return;
	}
}
Ejemplo n.º 13
0
int main( int argc, char* argv[] )
{ 
	try { 
		AppClient client;
		Map configDb;
		OmmConsumerConfig config;
		ServiceEndpointDiscovery serviceDiscovery;

		for ( int i = 1; i < argc; i++ )
		{
			if ( strcmp( argv[i], "-?" ) == 0 )
			{
				printHelp();
				return false;
			}
			else if ( strcmp( argv[i], "-username" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) userName.set( argv[++i] );
			}
			else if ( strcmp( argv[i] , "-password" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) password.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-location" ) == 0 )
			{
				if ( i < ( argc - 1) ) location.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-clientId" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) clientId.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-ph" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) proxyHostName.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-pp") == 0 )
			{
				if ( i < ( argc - 1 ) ) proxyPort.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-plogin" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) proxyUserName.set( argv[++i] );
			}
			else if ( strcmp( argv[i], "-ppasswd" ) == 0 )
			{
				if ( i < ( argc - 1 ) ) proxyPasswd.set( argv[++i] );
			}
			else if (strcmp(argv[i], "-pdomain" ) == 0)
			{
				if ( i < ( argc - 1 ) ) proxyDomain.set( argv[++i] );
			}
		}

		if ( !userName.length() || !password.length() )
		{
			cout << "Both username and password must be specified on the command line. Exiting...";
			printHelp();
			return -1;
		}

		// Query endpoints from EDP-RT service discovery for the TCP protocol
		serviceDiscovery.registerClient( ServiceEndpointDiscoveryOption().username( userName ).password( password )
			.clientId( clientId ).transprot( ServiceEndpointDiscoveryOption::TcpEnum )
			.proxyHostName( proxyHostName ).proxyPort( proxyPort ).proxyUserName( proxyUserName ).proxyPassword( proxyPasswd )
			.proxyDomain( proxyDomain ), client );

		if ( !host.length() || !port.length() )
		{
			cout << "Both hostname and port are not avaiable for establishing a connection with ERT in cloud. Exiting..." << endl;
			return -1;
		}

		createProgramaticConfig( configDb );

		OmmConsumer consumer( OmmConsumerConfig().consumerName( "Consumer_1" ).username( userName ).password( password )
			.clientId( clientId ).config( configDb ).tunnelingProxyHostName( proxyHostName ).tunnelingProxyPort( proxyPort )
			.proxyUserName( proxyUserName ).proxyPasswd( proxyPasswd ).proxyDomain( proxyDomain ) );

		consumer.registerClient( ReqMsg().serviceName( "ELEKTRON_DD" ).name( "IBM.N" ), client );
		sleep( 900000 );			// API calls onRefreshMsg(), onUpdateMsg(), or onStatusMsg()
	} catch ( const OmmException& excp ) {
		cout << excp << endl;
	}

	return 0;
}
Ejemplo n.º 14
0
void OmmOpaqueEncoder::set( const EmaString& value )
{
	encodeBuffer( value.c_str(), value.length() );
}