Пример #1
0
void LoginHandler::notifyChannelDown(ClientSession* clientSession)
{
	_pOmmServerBaseImpl->_userLock.lock();

	ItemInfo* itemInfo;

	for (UInt32 index = 0; index < _itemInfoList.size(); index++)
	{
		itemInfo = _itemInfoList[index];

		if (clientSession == itemInfo->getClientSession())
		{
			_pOmmServerBaseImpl->_reqMsg.clear();
			_pOmmServerBaseImpl->_reqMsg.initialImage(false);
			_pOmmServerBaseImpl->_reqMsg.interestAfterRefresh(false);
			_pOmmServerBaseImpl->_reqMsg.streamId(itemInfo->getStreamId());

			if (itemInfo->hasNameType())
			{
				_pOmmServerBaseImpl->_reqMsg.nameType(itemInfo->getNameType());
			}

			if (itemInfo->hasName())
			{
				_pOmmServerBaseImpl->_reqMsg.name(itemInfo->getName());
			}

			_pOmmServerBaseImpl->_reqMsg.domainType(MMT_LOGIN);

			StaticDecoder::setData(&_pOmmServerBaseImpl->_reqMsg, 0);

			_pOmmServerBaseImpl->ommProviderEvent._clientHandle = itemInfo->getClientSession()->getClientHandle();
			_pOmmServerBaseImpl->ommProviderEvent._closure = _pOmmServerBaseImpl->_pClosure;
			_pOmmServerBaseImpl->ommProviderEvent._provider = _pOmmServerBaseImpl->getProvider();
			_pOmmServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

			_pOmmServerBaseImpl->_pOmmProviderClient->onAllMsg(_pOmmServerBaseImpl->_reqMsg, _pOmmServerBaseImpl->ommProviderEvent);
			_pOmmServerBaseImpl->_pOmmProviderClient->onClose(_pOmmServerBaseImpl->_reqMsg, _pOmmServerBaseImpl->ommProviderEvent);

			break;
		}
	}

	_pOmmServerBaseImpl->_userLock.unlock();
}
Пример #2
0
RsslReactorCallbackRet LoginHandler::loginCallback(RsslReactor* pReactor, RsslReactorChannel* pReactorChannel, RsslRDMLoginMsgEvent* pRDMLoginMsgEvent)
{
	OmmServerBaseImpl* ommServerBaseImpl = (OmmServerBaseImpl*)pReactor->userSpecPtr;
	ommServerBaseImpl->eventReceived();

	ClientSession* clientSession = (ClientSession*)pReactorChannel->userSpecPtr;
	RsslRDMLoginMsg *pLoginMsg = pRDMLoginMsgEvent->pRDMLoginMsg;

	if (!pLoginMsg)
	{
		if (pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.msgClass == RSSL_MC_GENERIC)
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received Generic message on login stream.");
				temp.append(CR).append("Stream Id ").append(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId);

			if (itemInfo)
			{
				StaticDecoder::setRsslData(&ommServerBaseImpl->_genericMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
					pReactorChannel->majorVersion,
					pReactorChannel->minorVersion,
					0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onGenericMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}

		EmaString temp("Login message rejected - invalid login domain message.");

		ommServerBaseImpl->getLoginHandler().sendLoginReject(pReactorChannel, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId, RSSL_SC_USAGE_ERROR, temp);

		if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
		{
			temp.append(CR).append("Stream Id ").append(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->msgBase.streamId)
				.append(CR).append("Client handle ").append(clientSession->getClientHandle())
				.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

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

		return RSSL_RC_CRET_SUCCESS;
	}

	switch (pLoginMsg->rdmMsgBase.rdmMsgType)
	{
		case RDM_LG_MT_REQUEST:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received login request message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			StaticDecoder::setRsslData(&ommServerBaseImpl->_reqMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
				pReactorChannel->majorVersion,
				pReactorChannel->minorVersion,
				0);

			ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
			ommServerBaseImpl->ommProviderEvent._channel = pReactorChannel;
			ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
			ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (!itemInfo )
			{
				ItemInfo* itemInfo = ItemInfo::create(*ommServerBaseImpl);

				if (!itemInfo || !itemInfo->setRsslRequestMsg(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->requestMsg) )
					return RSSL_RC_CRET_SUCCESS;

				itemInfo->setClientSession(clientSession);

				ommServerBaseImpl->getLoginHandler().addItemInfo(itemInfo);
				ommServerBaseImpl->addItemInfo(itemInfo);

				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onReqMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
			}
			else
			{
				if ( !itemInfo->setRsslRequestMsg(pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg->requestMsg) )
					return RSSL_RC_CRET_SUCCESS;

				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;
				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onReissue(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		case RDM_LG_MT_CONSUMER_CONNECTION_STATUS:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received Consumer Connection Status message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (itemInfo)
			{
				StaticDecoder::setRsslData(&ommServerBaseImpl->_genericMsg, pRDMLoginMsgEvent->baseMsgEvent.pRsslMsg,
					pReactorChannel->majorVersion,
					pReactorChannel->minorVersion,
					0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onGenericMsg(ommServerBaseImpl->_genericMsg, ommServerBaseImpl->ommProviderEvent);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		case RDM_LG_MT_POST:
		{
			if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received post message on login domain.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName())
					.append(CR).append("Post message is not support for this release.").append(ommServerBaseImpl->getInstanceName());

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

			break;
		}
		case RDM_LG_MT_CLOSE:
		{
			if (OmmLoggerClient::VerboseEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				EmaString temp("Received login close message.");
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

				ommServerBaseImpl->getOmmLoggerClient().log(_clientName, OmmLoggerClient::VerboseEnum, temp);
			}

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			ommServerBaseImpl->_reqMsg.clear();
			ommServerBaseImpl->_reqMsg.initialImage(false);
			ommServerBaseImpl->_reqMsg.interestAfterRefresh(false);
			ommServerBaseImpl->_reqMsg.streamId(pLoginMsg->rdmMsgBase.streamId);

			if (itemInfo)
			{
				if (itemInfo->hasNameType())
				{
					ommServerBaseImpl->_reqMsg.nameType(itemInfo->getNameType());
				}

				if (itemInfo->hasName())
				{
					ommServerBaseImpl->_reqMsg.name(itemInfo->getName());
				}

				ommServerBaseImpl->_reqMsg.name(itemInfo->getName());
				ommServerBaseImpl->_reqMsg.domainType(itemInfo->getDomainType());

				StaticDecoder::setData(&ommServerBaseImpl->_reqMsg, 0);

				ommServerBaseImpl->ommProviderEvent._clientHandle = clientSession->getClientHandle();
				ommServerBaseImpl->ommProviderEvent._closure = ommServerBaseImpl->_pClosure;
				ommServerBaseImpl->ommProviderEvent._provider = ommServerBaseImpl->getProvider();
				ommServerBaseImpl->ommProviderEvent._handle = (UInt64)itemInfo;

				ommServerBaseImpl->_pOmmProviderClient->onAllMsg(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);
				ommServerBaseImpl->_pOmmProviderClient->onClose(ommServerBaseImpl->_reqMsg, ommServerBaseImpl->ommProviderEvent);

				ommServerBaseImpl->getServerChannelHandler().closeChannel(pReactorChannel);
			}

			return RSSL_RC_CRET_SUCCESS;
		}
		default:
		{
			EmaString temp("Rejected unhandled login message type ");
			temp.append(ConverterRdmLoginMsgTypeToStr[pLoginMsg->rdmMsgBase.rdmMsgType].strMsgType);

			ItemInfo* itemInfo = clientSession->getItemInfo(pLoginMsg->rdmMsgBase.streamId);

			if (!itemInfo)
			{
				ommServerBaseImpl->getLoginHandler().sendLoginReject(pReactorChannel, pLoginMsg->rdmMsgBase.streamId, RSSL_SC_USAGE_ERROR, temp);
			}

			if (OmmLoggerClient::ErrorEnum >= ommServerBaseImpl->getActiveConfig().loggerConfig.minLoggerSeverity)
			{
				temp.append(CR).append("Stream Id ").append(pLoginMsg->rdmMsgBase.streamId)
					.append(CR).append("Client handle ").append(clientSession->getClientHandle())
					.append(CR).append("Instance Name ").append(ommServerBaseImpl->getInstanceName());

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

	return RSSL_RC_CRET_SUCCESS;
}