/* ci has been cleared and calling function has verified that channel arguments are non-null.
 * Calling function has also updated hostname and ipAddress
 */
void thomsonreuters::ema::access::getChannelInformation(const RsslReactorChannel* rsslReactorChannel,
												 const RsslChannel* rsslChannel,
												 ChannelInformation& ci) {
  // create channel info
  EmaString componentInfo;
  RsslErrorInfo rsslErrorInfo;
  RsslReactorChannelInfo rsslReactorChannelInfo;

  // if channel is closed, rsslReactorGetChannelInfo does not succeed
  if (rsslReactorGetChannelInfo(const_cast<RsslReactorChannel*>(rsslReactorChannel),
								&rsslReactorChannelInfo, &rsslErrorInfo) == RSSL_RET_SUCCESS) {
	for (unsigned int i = 0; i < rsslReactorChannelInfo.rsslChannelInfo.componentInfoCount; ++i) {
	  componentInfo.append(rsslReactorChannelInfo.rsslChannelInfo.componentInfo[i]->componentVersion.data);
	  if (i < (rsslReactorChannelInfo.rsslChannelInfo.componentInfoCount - 1))
		componentInfo.append(", ");
	}
  }
  else
	componentInfo.append("unavailable");

  ci.connectedComponentInfo(componentInfo)
	.channelState(static_cast<ChannelInformation::ChannelState>(rsslChannel->state))
	.connectionType(static_cast<ChannelInformation::ConnectionType>(rsslChannel->connectionType))
	.protocolType(static_cast<ChannelInformation::ProtocolType>(rsslChannel->protocolType))
	.majorVersion(rsslChannel->majorVersion)
	.minorVersion(rsslChannel->minorVersion)
	.pingTimeout(rsslChannel->pingTimeout);
}
Пример #2
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 );
}
Пример #3
0
int main( int argc, char* argv[] )
{
	try { 
		AppClient client;
		OmmConsumer consumer( OmmConsumerConfig().host( "localhost:14002" ).username( "user" ) );
		ReqMsg reqMsg;
		EmaString itemName;
		for ( UInt32 idx = 0; idx < 1000; ++idx )
		{
			itemName.set( "RTR", 3 ).append( idx ).append( ".N" );
			reqMsg.serviceName( "DIRECT_FEED" ).name( itemName );
			consumer.registerClient( reqMsg, client );
			reqMsg.clear();
		}
		for ( UInt32 idx = 0; idx < 300; ++idx )
		{
			sleep( 1000 );
			cout << "total refresh count: " << refreshCount << "\ttotal status count: " << statusCount << "\tupdate rate (per sec): " << updateCount << endl;
			updateCount = 0;
		}
	} catch ( const OmmException& excp ) {
		cout << excp << endl;
	}
	return 0;
}
DataDictionaryImpl::FieldNameToIdHash* DataDictionaryImpl::fieldNameToIdMap() const
{
	if ( _loadedFieldDictionary )
	{
		if ( _pfieldNameToIdHash == 0 )
		{
			_pfieldNameToIdHash = new FieldNameToIdHash(_pRsslDataDictionary->numberOfEntries);
		}

		if ( _pfieldNameToIdHash->empty() )
		{
			RsslDictionaryEntry* rsslDictionaryEntry = 0;
			EmaString fieldName;

			for (Int32 index = _pRsslDataDictionary->minFid; index <= _pRsslDataDictionary->maxFid; index++)
			{
				rsslDictionaryEntry = *(_pRsslDataDictionary->entriesArray + index);

				if (rsslDictionaryEntry)
				{
					fieldName.set(rsslDictionaryEntry->acronym.data, rsslDictionaryEntry->acronym.length);
					_pfieldNameToIdHash->insert(fieldName, rsslDictionaryEntry->fid);
				}
			}
		}
	}

	return _pfieldNameToIdHash;
}
Пример #5
0
char& EmaString::operator[] ( UInt32 pos )
{
    if ( pos > _length )
    {
        EmaString text ( "Attempt to access out of range position in EmaString::operator[](). Passed in index is " );
        text.append ( pos ).append ( " while length is " ).append ( _length ).append ( "." );
        throwOorException ( text );
    }

    return _pString[pos];
}
Пример #6
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()");
}
Пример #7
0
void hexToString( EmaString& output, const EmaBuffer& in )
{
	for ( UInt32 idx = 0; idx < in.length(); ++idx )
	{
		char charOmmArray[10];

		hexToChar( charOmmArray, *(in.c_buf() + idx) );

		output.append( charOmmArray );
		
		if ( in.length() > 1 && idx < in.length() - 1 ) output.append( " " );
	}
}
Пример #8
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()");
}
Пример #9
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;
}
Пример #10
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 );
}
Пример #11
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()" );
	}
}
Пример #12
0
const EmaString& OmmError::getErrorCodeAsString() const
{
	switch ( getErrorCode() )
	{
	case NoErrorEnum :
		return NoErrorString;
	case NoDictionaryEnum :
		return NoDictionaryString;
	case FieldIdNotFoundEnum :
		return FieldIdNotFoundString;
	case IteratorOverrunEnum :
		return IteratorOverrunString;
	case IteratorSetFailureEnum :
		return IteratorSetFailureString;
	case IncompleteDataEnum :
		return IncompleteDataString;
	case NoSetDefinitionEnum :
		return NoSetDefinitionString;
	case UnsupportedDataTypeEnum :
		return UnsupportedDataTypeString;
	case UnknownErrorEnum :
		return UnknownErrorString;
	default :
		return TempErrorCodeString.set( "Unrecognized ErrorCode value " ).append( (Int64)getErrorCode() );
	}
}
Пример #13
0
const EmaString& getNCodeAsString( UInt16 nCode )
{
	switch ( nCode )
	{
	case AckMsg::NoneEnum :
		return NoneString;
	case AckMsg::AccessDeniedEnum:
		return AccessDeniedString;
	case AckMsg::DeniedBySourceEnum:
		return DeniedBySourceString;
	case AckMsg::SourceDownEnum:
		return SourceDownString;
	case AckMsg::SourceUnknownEnum:
		return SourceUnknownString;
	case AckMsg::NoResourcesEnum:
		return NoResourcesString;
	case AckMsg::NoResponseEnum:
		return NoResponseString;
	case AckMsg::GatewayDownEnum :
		return GatewayDownString;
	case AckMsg::SymbolUnknownEnum:
		return SymbolUnknownString;
	case AckMsg::NotOpenEnum:
		return NotOpenString;
	case AckMsg::InvalidContentEnum :
		return InvalidContentString;
	default :
		return TempNCString.set( "Unknown NackCode value " ).append( nCode );
	}
}
Пример #14
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 );
}
Пример #15
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()" );
	}
}
Пример #16
0
const EmaString& getFActionAsString( FilterEntry::FilterAction action )
{
	switch ( action )
	{
	case FilterEntry::SetEnum :
		return SetString;
	case FilterEntry::UpdateEnum :
		return UpdateString;
	case FilterEntry::ClearEnum :
		return ClearString;
	default :
		{
			TempFAString.set( "Unknown FilterAction value " );
			TempFAString.append( (Int64)action );
		}
		return TempFAString;
	}
}
Пример #17
0
EmaString EmaString::substr ( UInt32 index, UInt32 length ) const
{
    if ( length != EmaString::npos &&
            ( index > _length ||
              index + length > _length )
       )
    {
        EmaString text ( "Attempt to access out of range position in EmaString::substr( UInt32 , UInt32 ) const. Passed in index is " );
        text.append ( index ).append ( " and passed in length is " ).append ( length ).append ( " while length is " ).append ( _length ).append ( "." );
        throwOorException ( text );
        return EmaString();
    }

    EmaString retVal;

    retVal.set ( _pString + index, length );

    return retVal;
}
Пример #18
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();
		}
	}
}
Пример #19
0
const EmaString& OmmQos::getRateAsString() const
{
	switch ( getRate() )
	{
	case TickByTickEnum :
		return TickByTickRateName;
	case JustInTimeConflatedEnum :
		return JustInTimeConflatedRateName;
	default :
		return UnknownQosRateName.set( "Rate: " ).append( (UInt64)getRate() );
	}
}
Пример #20
0
const EmaString& Data::getCodeAsString() const
{
	switch ( getCode() )
	{
	case NoCodeEnum :
		return NoCodeString;
	case BlankEnum :
		return BlankString;
	default :
		return TempDCString.set( "Unknown DataCode value " ).append( (Int64)getCode() );
	}
}
Пример #21
0
const EmaString& OmmQos::getTimelinessAsString() const
{
	switch ( getTimeliness() )
	{
	case RealTimeEnum :
		return RealTimeTimelinessName;
	case InexactDelayedEnum :
		return InexactDelayedTimelinessName;
	default :
		return UnknownQosTimelinessName.set( "Timeliness: " ).append( (UInt64)getTimeliness() );
	}
}
Пример #22
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 );
}
Пример #23
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 );
}
Пример #24
0
const EmaString& getVActionAsString( VectorEntry::VectorAction vAction )
{
	switch ( vAction )
	{
	case VectorEntry::SetEnum :
		return SetString;
	case VectorEntry::UpdateEnum :
		return UpdateString;
	case VectorEntry::ClearEnum:
		return ClearString;
	case VectorEntry::InsertEnum:
		return InsertString;
	case VectorEntry::DeleteEnum :
		return DeleteString;
	default :
		return TempVAString.set( "Unknown VectorAction value " ).append( (Int64)vAction );
	}
}
Пример #25
0
const EmaString& getDTypeAsString( DataType::DataTypeEnum dType )
{
	switch ( dType )
	{
	case DataType::ReqMsgEnum :
		return ReqMsgString;
	case DataType::RefreshMsgEnum :
		return RefreshMsgString;
	case DataType::StatusMsgEnum :
		return StatusMsgString;
	case DataType::UpdateMsgEnum :
		return UpdateMsgString;
	case DataType::PostMsgEnum :
		return PostMsgString;
	case DataType::AckMsgEnum :
		return AckMsgString;
	case DataType::GenericMsgEnum :
		return GenericMsgString;
	case DataType::FieldListEnum :
		return FieldListString;
	case DataType::ElementListEnum :
		return ElementListString;
	case DataType::MapEnum :
		return MapString;
	case DataType::VectorEnum :
		return VectorString;
	case DataType::SeriesEnum :
		return SeriesString;
	case DataType::FilterListEnum :
		return FilterListString;
	case DataType::OpaqueEnum :
		return OpaqueString;
	case DataType::XmlEnum :
		return XmlString;
	case DataType::AnsiPageEnum :
		return AnsiPageString;
	case DataType::ArrayEnum :
		return OmmArrayString;
	case DataType::IntEnum :
		return IntString;
	case DataType::UIntEnum :
		return UIntString;
	case DataType::RealEnum :
		return RealString;
	case DataType::FloatEnum :
		return FloatString;
	case DataType::DoubleEnum :
		return DoubleString;
	case DataType::DateEnum :
		return DateString;
	case DataType::TimeEnum :
		return TimeString;
	case DataType::DateTimeEnum :
		return DateTimeString;
	case DataType::QosEnum :
		return QosString;
	case DataType::StateEnum :
		return StateString;
	case DataType::EnumEnum :
		return EnumString;
	case DataType::BufferEnum :
		return BufferString;
	case DataType::AsciiEnum :
		return AsciiString;
	case DataType::Utf8Enum :
		return Utf8String;
	case DataType::RmtesEnum :
		return RmtesString;
	case DataType::NoDataEnum :
		return NoDataString;
	case DataType::ErrorEnum :
		return ErrorString;
	default :
		return TempDTString.set( "Unknown DataType value " ).append( (UInt64)dType );
	}
}
Пример #26
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;
}
void ChannelCallbackClient::initialize( RsslRDMLoginRequest* loginRequest, RsslRDMDirectoryRequest* dirRequest )
{
	RsslReactorOMMConsumerRole consumerRole;
	rsslClearOMMConsumerRole( &consumerRole );

	consumerRole.pLoginRequest = loginRequest;
	consumerRole.pDirectoryRequest = dirRequest;
	consumerRole.dictionaryDownloadMode = RSSL_RC_DICTIONARY_DOWNLOAD_NONE;
	consumerRole.loginMsgCallback = OmmConsumerImpl::loginCallback;
	consumerRole.directoryMsgCallback = OmmConsumerImpl::directoryCallback;
	consumerRole.dictionaryMsgCallback = OmmConsumerImpl::dictionaryCallback;
	consumerRole.base.channelEventCallback = OmmConsumerImpl::channelCallback;
	consumerRole.base.defaultMsgCallback = OmmConsumerImpl::itemCallback;
	consumerRole.watchlistOptions.channelOpenCallback = OmmConsumerImpl::channelOpenCallback;
	consumerRole.watchlistOptions.enableWatchlist = RSSL_TRUE;
	consumerRole.watchlistOptions.itemCountHint = _ommConsImpl.getActiveConfig().itemCountHint;
	consumerRole.watchlistOptions.obeyOpenWindow = _ommConsImpl.getActiveConfig().obeyOpenWindow > 0 ? RSSL_TRUE : RSSL_FALSE;
	consumerRole.watchlistOptions.postAckTimeout = _ommConsImpl.getActiveConfig().postAckTimeout;
	consumerRole.watchlistOptions.requestTimeout = _ommConsImpl.getActiveConfig().requestTimeout;
	consumerRole.watchlistOptions.maxOutstandingPosts = _ommConsImpl.getActiveConfig().maxOutstandingPosts;
		
	EmaVector< ChannelConfig* > &consumerActivecfgChannelSet = _ommConsImpl.getActiveConfig().configChannelSet;
	unsigned int channelCfgSetLastIndex = consumerActivecfgChannelSet.size() - 1;

	RsslReactorConnectInfo      *reactorConnectInfo = new RsslReactorConnectInfo[consumerActivecfgChannelSet.size()];
	RsslReactorConnectOptions connectOpt;
	rsslClearReactorConnectOptions( &connectOpt );
	connectOpt.connectionCount = consumerActivecfgChannelSet.size();
	connectOpt.reactorConnectionList = reactorConnectInfo;
	connectOpt.reconnectAttemptLimit = consumerActivecfgChannelSet[channelCfgSetLastIndex]->reconnectAttemptLimit;
	connectOpt.reconnectMinDelay = consumerActivecfgChannelSet[channelCfgSetLastIndex]->reconnectMinDelay;
	connectOpt.reconnectMaxDelay = consumerActivecfgChannelSet[channelCfgSetLastIndex]->reconnectMaxDelay;
	connectOpt.initializationTimeout = 5;

	EmaString channelParams;
	EmaString temp( "Attempt to connect using ");
	if(connectOpt.connectionCount > 1)
		temp = "Attempt to connect using the following list";
	UInt32 supportedConnectionTypeChannelCount = 0;
	EmaString errorStrUnsupportedConnectionType("Unknown connection type. Passed in type is");

	EmaString channelNames;

	
	for(unsigned int i = 0; i < connectOpt.connectionCount; ++i)
	{
		rsslClearReactorConnectInfo(&reactorConnectInfo[i]);

		if ( consumerActivecfgChannelSet[i]->connectionType == RSSL_CONN_TYPE_SOCKET   ||
			consumerActivecfgChannelSet[i]->connectionType == RSSL_CONN_TYPE_HTTP ||
			consumerActivecfgChannelSet[i]->connectionType == RSSL_CONN_TYPE_ENCRYPTED ||
			consumerActivecfgChannelSet[i]->connectionType == RSSL_CONN_TYPE_RELIABLE_MCAST)
		{
			Channel* pChannel = Channel::create( _ommConsImpl, consumerActivecfgChannelSet[i]->name, _pRsslReactor );

			reactorConnectInfo[i].rsslConnectOptions.userSpecPtr = (void*)pChannel;
			consumerActivecfgChannelSet[i]->pChannel = pChannel;

			reactorConnectInfo[i].rsslConnectOptions.majorVersion = RSSL_RWF_MAJOR_VERSION;
			reactorConnectInfo[i].rsslConnectOptions.minorVersion = RSSL_RWF_MINOR_VERSION;
			reactorConnectInfo[i].rsslConnectOptions.protocolType = RSSL_RWF_PROTOCOL_TYPE;		
			reactorConnectInfo[i].rsslConnectOptions.connectionType = consumerActivecfgChannelSet[i]->connectionType;
			reactorConnectInfo[i].rsslConnectOptions.pingTimeout = consumerActivecfgChannelSet[i]->connectionPingTimeout;
			reactorConnectInfo[i].rsslConnectOptions.guaranteedOutputBuffers = consumerActivecfgChannelSet[i]->guaranteedOutputBuffers;
			reactorConnectInfo[i].rsslConnectOptions.sysRecvBufSize = consumerActivecfgChannelSet[i]->sysRecvBufSize;
			reactorConnectInfo[i].rsslConnectOptions.sysSendBufSize = consumerActivecfgChannelSet[i]->sysSendBufSize;
			reactorConnectInfo[i].rsslConnectOptions.numInputBuffers = consumerActivecfgChannelSet[i]->numInputBuffers;

			EmaString strConnectionType;
			switch ( reactorConnectInfo[i].rsslConnectOptions.connectionType )
			{
			case RSSL_CONN_TYPE_SOCKET:
				{
				reactorConnectInfo[i].rsslConnectOptions.compressionType = consumerActivecfgChannelSet[i]->compressionType;
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.address = (char*)static_cast<SocketChannelConfig*>(consumerActivecfgChannelSet[i])->hostName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.serviceName = (char*)static_cast<SocketChannelConfig*>(consumerActivecfgChannelSet[i])->serviceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.tcpOpts.tcp_nodelay = static_cast<SocketChannelConfig*>(consumerActivecfgChannelSet[i])->tcpNodelay;
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.interfaceName = (char*)consumerActivecfgChannelSet[i]->interfaceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.unicastServiceName = (char *) "";
				break;
				}
			case RSSL_CONN_TYPE_ENCRYPTED:
				{
				reactorConnectInfo[i].rsslConnectOptions.compressionType = consumerActivecfgChannelSet[i]->compressionType;
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.address = (char*)static_cast<EncryptedChannelConfig*>(consumerActivecfgChannelSet[i])->hostName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.serviceName = (char*)static_cast<EncryptedChannelConfig*>(consumerActivecfgChannelSet[i])->serviceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.tcpOpts.tcp_nodelay = static_cast<EncryptedChannelConfig*>(consumerActivecfgChannelSet[i])->tcpNodelay;
				reactorConnectInfo[i].rsslConnectOptions.objectName = (char*) static_cast<EncryptedChannelConfig*>(consumerActivecfgChannelSet[i])->objectName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.interfaceName = (char*)consumerActivecfgChannelSet[i]->interfaceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.unicastServiceName = (char *) "";
				break;
				}
			case RSSL_CONN_TYPE_HTTP:
				{
				reactorConnectInfo[i].rsslConnectOptions.compressionType = consumerActivecfgChannelSet[i]->compressionType;
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.address = (char*)static_cast<HttpChannelConfig*>(consumerActivecfgChannelSet[i])->hostName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.serviceName = (char*)static_cast<HttpChannelConfig*>(consumerActivecfgChannelSet[i])->serviceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.tcpOpts.tcp_nodelay = static_cast<HttpChannelConfig*>(consumerActivecfgChannelSet[i])->tcpNodelay;
				reactorConnectInfo[i].rsslConnectOptions.objectName = (char*) static_cast<HttpChannelConfig*>(consumerActivecfgChannelSet[i])->objectName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.interfaceName = (char*)consumerActivecfgChannelSet[i]->interfaceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.unified.unicastServiceName = (char *) "";
				strConnectionType = "RSSL_CONN_TYPE_HTTP";
				break;
				}
			case RSSL_CONN_TYPE_RELIABLE_MCAST:
				{
				ReliableMcastChannelConfig *relMcastCfg = static_cast<ReliableMcastChannelConfig*>(consumerActivecfgChannelSet[i]);
				if(consumerActivecfgChannelSet[i]->interfaceName.empty())
					reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.interfaceName = 0;
				else 
					reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.interfaceName = (char*)consumerActivecfgChannelSet[i]->interfaceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.recvAddress = (char*) relMcastCfg->recvAddress.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.recvServiceName = (char*) relMcastCfg->recvServiceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.unicastServiceName = (char*) relMcastCfg->unicastServiceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.sendAddress = (char*) relMcastCfg->sendAddress.c_str();
				reactorConnectInfo[i].rsslConnectOptions.connectionInfo.segmented.sendServiceName = (char*) relMcastCfg->sendServiceName.c_str();
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.disconnectOnGaps = relMcastCfg->disconnectOnGap;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.hsmInterface = (char *) relMcastCfg->hsmInterface.c_str();
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.hsmMultAddress = (char *) relMcastCfg->hsmMultAddress.c_str();
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.hsmPort = (char *) relMcastCfg->hsmPort.c_str();
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.hsmInterval =  relMcastCfg->hsmInterval;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.packetTTL =  relMcastCfg->packetTTL;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.tcpControlPort = (char *) relMcastCfg->tcpControlPort.c_str();
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.ndata =  relMcastCfg->ndata;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.nmissing =  relMcastCfg->nmissing;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.nrreq =  relMcastCfg->nrreq;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.tdata =  relMcastCfg->tdata;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.trreq =  relMcastCfg->trreq;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.twait =  relMcastCfg->twait;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.tpphold =  relMcastCfg->tpphold;
				reactorConnectInfo[i].rsslConnectOptions.multicastOpts.tbchold =  relMcastCfg->tbchold;
				break;
				}
			default :
				break;
			}

			pChannel->setChannelState( Channel::ChannelDownEnum );
			_channelList.addChannel( pChannel );
			supportedConnectionTypeChannelCount++;

			channelNames += pChannel->getName();
			if(i < channelCfgSetLastIndex)
			{
				channelNames.append(", ");
				consumerActivecfgChannelSet[i]->reconnectAttemptLimit = connectOpt.reconnectAttemptLimit;
				consumerActivecfgChannelSet[i]->reconnectMaxDelay = connectOpt.reconnectMaxDelay;
				consumerActivecfgChannelSet[i]->reconnectMinDelay = connectOpt.reconnectMinDelay;
				consumerActivecfgChannelSet[i]->xmlTraceFileName =  consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceFileName;
				consumerActivecfgChannelSet[i]->xmlTraceToFile = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceToFile;
				consumerActivecfgChannelSet[i]->xmlTraceToStdout = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceToStdout;
				consumerActivecfgChannelSet[i]->xmlTraceToMultipleFiles = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceToMultipleFiles;
				consumerActivecfgChannelSet[i]->xmlTraceWrite = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceWrite;
				consumerActivecfgChannelSet[i]->xmlTraceRead = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceRead;
				consumerActivecfgChannelSet[i]->xmlTraceMaxFileSize = consumerActivecfgChannelSet[channelCfgSetLastIndex]->xmlTraceMaxFileSize;
				consumerActivecfgChannelSet[i]->msgKeyInUpdates = consumerActivecfgChannelSet[channelCfgSetLastIndex]->msgKeyInUpdates;
			}

			if ( OmmLoggerClient::VerboseEnum >= _ommConsImpl.getActiveConfig().loggerConfig.minLoggerSeverity )
			{
				channelParams.clear();
				channelParametersToString(consumerActivecfgChannelSet[i], channelParams);
				temp.append( CR ).append(i+1).append("] ").append(channelParams);
					if(i == (connectOpt.connectionCount -1))
						_ommConsImpl.getOmmLoggerClient().log( _clientName, OmmLoggerClient::VerboseEnum, temp );
			}
		}
		else
		{
			reactorConnectInfo[i].rsslConnectOptions.userSpecPtr = 0;
			errorStrUnsupportedConnectionType.append( consumerActivecfgChannelSet[i]->connectionType )
			.append(" for ")
			.append(consumerActivecfgChannelSet[i]->name);
			if(i < channelCfgSetLastIndex)
				errorStrUnsupportedConnectionType.append(", ");
		}
	} 

	if(supportedConnectionTypeChannelCount > 0)
	{
		connectOpt.rsslConnectOptions.userSpecPtr = (void*) consumerActivecfgChannelSet[0]->pChannel;

		RsslErrorInfo rsslErrorInfo;
		if ( RSSL_RET_SUCCESS != rsslReactorConnect( _pRsslReactor, &connectOpt, (RsslReactorChannelRole*)(&consumerRole), &rsslErrorInfo ) )
		{

			EmaString temp( "Failed to add RsslChannel(s) to RsslReactor. Channel name(s) " );
			temp.append(channelNames ).append( CR )
				.append( "Consumer Name " ).append( _ommConsImpl.getConsumerName() ).append( CR )
				.append( "RsslReactor " ).append( ptrToStringAsHex( _pRsslReactor ) ).append( CR )
				.append( "RsslChannel " ).append( (UInt64)rsslErrorInfo.rsslError.channel ).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 );

			if ( OmmLoggerClient::ErrorEnum >= _ommConsImpl.getActiveConfig().loggerConfig.minLoggerSeverity )
				_ommConsImpl.getOmmLoggerClient().log( _clientName, OmmLoggerClient::ErrorEnum, temp.trimWhitespace() );

			for(unsigned int i = 0; i < connectOpt.connectionCount; ++i)
			{
				Channel *pChannel =(Channel *) reactorConnectInfo[i].rsslConnectOptions.userSpecPtr;
				if(pChannel)
					Channel::destroy( pChannel );
			}

			delete [] reactorConnectInfo;
			throwIueException( temp );

			return;
		}

		_ommConsImpl.setState( OmmConsumerImpl::RsslChannelDownEnum );
		

		if ( OmmLoggerClient::VerboseEnum >= _ommConsImpl.getActiveConfig().loggerConfig.minLoggerSeverity )
		{
			EmaString temp( "Successfully created a Reactor and Channel(s)" );
			temp.append( CR )
				.append(" Channel name(s) " ).append( channelNames ).append( CR )
				.append( "Consumer Name " ).append( _ommConsImpl.getConsumerName() );
			_ommConsImpl.getOmmLoggerClient().log( _clientName, OmmLoggerClient::VerboseEnum, temp );
		}	

		if(supportedConnectionTypeChannelCount < connectOpt.connectionCount)
			_ommConsImpl.getOmmLoggerClient().log( _clientName, OmmLoggerClient::WarningEnum, errorStrUnsupportedConnectionType );
	}
	else
	{
		delete [] reactorConnectInfo;
		throwIueException( errorStrUnsupportedConnectionType );
	}
	delete [] reactorConnectInfo;
}
Пример #28
0
void OmmOpaqueEncoder::set( const EmaString& value )
{
	encodeBuffer( value.c_str(), value.length() );
}
Пример #29
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;
	}
}
Пример #30
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;
}