in src/dxapi/native/tickdb/http/tickcursor_http.cpp [363:421]
void TickCursorImpl::registerNewMessageType(SubscriptionState &s, unsigned newMsgDescId, const string &data)
{
unsigned expectedId = (unsigned)s.tables_.messageDescriptors.size();
if (expectedId != newMsgDescId) {
THROW_DBGLOG(LOGHDR ": Cursor symbol cache out of sync: New message type id: %u was unexpected, the next expected value is: %u",
ID, newMsgDescId, expectedId);
}
//DBGLOG("New Message type :\n%s", data.c_str());
Schema::TickDbClassDescriptorImpl classDescriptor;
if (!classDescriptor.fromXML(data)) {
THROW_DBGLOG(LOGHDR ": unable to parse messageDescriptor with id %u from XML text: %s",
ID, newMsgDescId, data.c_str());
}
const string &typeName = classDescriptor.className;
const string &typeGuid = classDescriptor.guid;
// NOTE: Previously we also saved the info about stream id etc. This code is now removed and streams are identified and filtered by stream id
// due to impossibility of distinguishing messages by GUID.
auto msgDesc = s.tables_.registerMessageDescriptor(newMsgDescId, typeName, typeGuid, data);
auto &filter = s.isMessageDescriptorSkipped_;
uint8_t isSkipped = false;
// Verify correctness
assert(msgDesc->id == newMsgDescId);
assert(newMsgDescId == s.tables_.findMsgDescByType(typeName));
{
const auto i = s.isUnregisteredMessageTypeSkipped_.find(typeName);
if (s.isUnregisteredMessageTypeSkipped_.cend() != i) {
// We had a filter entry for this message before it came up.
// Supposedly, we have never encountered this message type. TODO: Maybe we added it while preparing filtering tables?
isSkipped = i->second;
s.isUnregisteredMessageTypeSkipped_.erase(i);
}
else {
unsigned sibling = msgDesc->nextSameType;
// Propagate filter value from sibling(all messages with the same name share filtering status), or use current default value
isSkipped = EMPTY_MSG_TYPE_ID == sibling ? filter.defaultValue() : filter.get(sibling);
}
}
filter.set(newMsgDescId, isSkipped);
const char *sysmsg = "";
if (isSystemMessageGuid(typeGuid.c_str())) {
sysmsg = "system ";
assert(newMsgDescId < COUNTOF(isSystemMessage_));
isSystemMessage_[newMsgDescId] = true;
}
DBGLOG(LOGHDR ": Added %smessage descriptor: %s(%s) = %u", ID, sysmsg, typeName.c_str(), typeGuid.c_str(), newMsgDescId);
}