/* * Processes all RSSL messages that aren't processed by * any domain-specific callback functions. * Item requests are handled here. */ RsslReactorCallbackRet defaultMsgCallback(RsslReactor *pReactor, RsslReactorChannel *pReactorChannel, RsslMsgEvent *pRsslMsgEvent) { RsslDecodeIterator dIter; RsslMsg *pRsslMsg = pRsslMsgEvent->pRsslMsg; if (!pRsslMsg) { RsslErrorInfo *pError = pRsslMsgEvent->pErrorInfo; printf("defaultMsgCallback() received error: %s(%s)\n", pError->rsslError.text, pError->errorLocation); removeClientSessionForChannel(pReactor, pReactorChannel); return RSSL_RC_CRET_SUCCESS; } /* clear decode iterator */ rsslClearDecodeIterator(&dIter); rsslSetDecodeIteratorRWFVersion(&dIter, pReactorChannel->majorVersion, pReactorChannel->minorVersion); rsslSetDecodeIteratorBuffer(&dIter, &pRsslMsg->msgBase.encDataBody); switch ( pRsslMsg->msgBase.domainType ) { case RSSL_DMT_MARKET_PRICE: case RSSL_DMT_MARKET_BY_ORDER: case RSSL_DMT_MARKET_BY_PRICE: case RSSL_DMT_YIELD_CURVE: case RSSL_DMT_SYMBOL_LIST: if (processItemRequest(pReactor, pReactorChannel, pRsslMsg, &dIter) != RSSL_RET_SUCCESS) { removeClientSessionForChannel(pReactor, pReactorChannel); return RSSL_RC_CRET_SUCCESS; } break; default: switch(pRsslMsg->msgBase.msgClass) { case RSSL_MC_REQUEST: if (sendNotSupportedStatus(pReactor, pReactorChannel, pRsslMsg) != RSSL_RET_SUCCESS) { removeClientSessionForChannel(pReactor, pReactorChannel); return RSSL_RC_CRET_SUCCESS; } break; case RSSL_MC_CLOSE: printf("Received Close message with StreamId %d and unsupported domain %u\n\n", pRsslMsg->msgBase.streamId, pRsslMsg->msgBase.domainType); break; default: printf("Received unhandled message with MsgClass %u, StreamId %d and unsupported domain %u\n\n", pRsslMsg->msgBase.msgClass, pRsslMsg->msgBase.streamId, pRsslMsg->msgBase.domainType); break; } break; } return RSSL_RC_CRET_SUCCESS; }
RsslReactorCallbackRet defaultMsgCallback(RsslReactor *pReactor, RsslReactorChannel *pReactorChannel, RsslMsgEvent* pMsgEvent) { ProviderSession *pProvSession = (ProviderSession *)pReactorChannel->userSpecPtr; ProviderThread *pProvThread = pProvSession->pProviderThread; RsslMsg *pMsg = pMsgEvent->pRsslMsg; RsslDecodeIterator dIter; /* clear decode iterator */ rsslClearDecodeIterator(&dIter); /* set version info */ rsslSetDecodeIteratorRWFVersion(&dIter, pReactorChannel->majorVersion, pReactorChannel->minorVersion); rsslSetDecodeIteratorBuffer(&dIter, &pMsg->msgBase.encDataBody); switch (pMsg->msgBase.domainType) { case RSSL_DMT_MARKET_PRICE: if (xmlMsgDataHasMarketPrice) processItemRequest(pProvThread, pProvSession, pMsg, &dIter); else sendItemRequestReject(pProvThread, pProvSession, pMsg->msgBase.streamId, pMsg->msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; case RSSL_DMT_MARKET_BY_ORDER: if (xmlMsgDataHasMarketByOrder) processItemRequest(pProvThread, pProvSession, pMsg, &dIter); else sendItemRequestReject(pProvThread, pProvSession, pMsg->msgBase.streamId, pMsg->msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; default: sendItemRequestReject(pProvThread, pProvSession, pMsg->msgBase.streamId, pMsg->msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; } return RSSL_RC_CRET_SUCCESS; }
RsslRet processMsg(ChannelHandler *pChannelHandler, ChannelInfo* pChannelInfo, RsslBuffer* pBuffer) { RsslRet ret = RSSL_RET_SUCCESS; RsslMsg msg = RSSL_INIT_MSG; RsslDecodeIterator dIter; ProviderThread *pProvThread = (ProviderThread*)pChannelHandler->pUserSpec; RsslChannel *pChannel = pChannelInfo->pChannel; /* clear decode iterator */ rsslClearDecodeIterator(&dIter); /* set version info */ rsslSetDecodeIteratorRWFVersion(&dIter, pChannel->majorVersion, pChannel->minorVersion); rsslSetDecodeIteratorBuffer(&dIter, pBuffer); ret = rsslDecodeMsg(&dIter, &msg); if (ret != RSSL_RET_SUCCESS) { printf("\nrsslDecodeMsg(): Error %d on SessionData fd=%d Size %d \n", ret, pChannel->socketId, pBuffer->length); cleanUpAndExit(); } switch ( msg.msgBase.domainType ) { case RSSL_DMT_LOGIN: ret = processLoginRequest(pChannelHandler, pChannelInfo, &msg, &dIter); break; case RSSL_DMT_SOURCE: ret = processDirectoryRequest(pChannelHandler, pChannelInfo, &msg, &dIter); break; case RSSL_DMT_DICTIONARY: ret = processDictionaryRequest(pChannelHandler, pChannelInfo, &msg, &dIter); break; case RSSL_DMT_MARKET_PRICE: if (xmlMsgDataHasMarketPrice) ret = processItemRequest(pProvThread, (ProviderSession*)pChannelInfo->pUserSpec, &msg, &dIter); else ret = sendItemRequestReject(pProvThread, (ProviderSession*)pChannelInfo->pUserSpec, msg.msgBase.streamId, msg.msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; case RSSL_DMT_MARKET_BY_ORDER: if (xmlMsgDataHasMarketByOrder) ret = processItemRequest(pProvThread, (ProviderSession*)pChannelInfo->pUserSpec, &msg, &dIter); else ret = sendItemRequestReject(pProvThread, (ProviderSession*)pChannelInfo->pUserSpec, msg.msgBase.streamId, msg.msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; default: ret = sendItemRequestReject(pProvThread, (ProviderSession*)pChannelInfo->pUserSpec, msg.msgBase.streamId, msg.msgBase.domainType, DOMAIN_NOT_SUPPORTED); break; } if (ret < RSSL_RET_SUCCESS) { printf("Failed to process request from domain %d: %d\n", msg.msgBase.domainType, ret); } else if (ret > RSSL_RET_SUCCESS) { /* The function sent a message and indicated that we need to flush. */ providerThreadRequestChannelFlush(pProvThread, pChannelInfo); } return ret; }