diff --git a/codegenerator/cpp/helper.js b/codegenerator/cpp/helper.js index c67600e2..cea2c777 100644 --- a/codegenerator/cpp/helper.js +++ b/codegenerator/cpp/helper.js @@ -69,16 +69,16 @@ module.exports = { { if (type) { - var type = type; + var typeWithNamespace = type; if (type.split('.').length > 1 || data.namespace == null || data.namespace.length == 0 || !this.isTypeInData(data, type)) { - type = type; + typeWithNamespace = type; } else { - type = data.namespace + '.' + type + typeWithNamespace = data.namespace + '.' + type } - return type.split('.').join(delimiter) + return typeWithNamespace.split('.').join(delimiter) } else { diff --git a/htdocs/fmq.js b/htdocs/fmq.js index 75535031..9df27e15 100644 --- a/htdocs/fmq.js +++ b/htdocs/fmq.js @@ -366,28 +366,40 @@ class FmqSession response = response.substring(ixStart); if (response.length > 0) { + var jsonHeaderParams = response.substring(1).split(',\t'); response += ']'; var command = xmlhttp._this._getParams(response); var header = command[0]; var params = command[1]; params.fmqheader = header; + params.fmqheaderjson = jsonHeaderParams[0]; + params.fmqparamsjson = ''; + if (jsonHeaderParams.length >= 2) + { + params.fmqparamsjson = jsonHeaderParams[1]; + } params.httpstatus = xmlhttp.status; var path = header.path; if (!path || path == '') { - path = header.type.replace(/\./g, '_'); // replace all '.' by '_' + path = header.type; } else { path = path.replace(/\//g, '_'); // replace all '/' by '_' } + path = path.replace(/\./g, '_'); // replace all '.' by '_' var entity = xmlhttp._this._getEntity(header.srcid); if (entity && entity[path]) { entity[path](header.corrid, params); } - else + else if (entity && entity['allRequests']) + { + entity['allRequests'](header.corrid, path, params); + } + else { xmlhttp._this.replyStatus(header.srcid, header.corrid, 'STATUS_REQUEST_NOT_FOUND'); } diff --git a/inc/finalmq/metadataserialize/MetaDataExchange.h b/inc/finalmq/metadataserialize/MetaDataExchange.h index b773ece9..7d2ec355 100644 --- a/inc/finalmq/metadataserialize/MetaDataExchange.h +++ b/inc/finalmq/metadataserialize/MetaDataExchange.h @@ -20,6 +20,7 @@ //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE. +#pragma once #include "finalmq/metadataserialize/metadata.fmq.h" diff --git a/src/metadataserialize/MetaDataExchange.cpp b/src/metadataserialize/MetaDataExchange.cpp index 2b8b4c61..331f337c 100644 --- a/src/metadataserialize/MetaDataExchange.cpp +++ b/src/metadataserialize/MetaDataExchange.cpp @@ -45,6 +45,29 @@ static SerializeMetaTypeId convert(MetaTypeId value) return static_cast(static_cast(value)); } +static bool isInData(const SerializeMetaData& metadata, const std::string& type) +{ + // enums + for (size_t i = 0; i < metadata.enums.size(); ++i) + { + const SerializeMetaEnum& enumSource = metadata.enums[i]; + if (enumSource.type == type) + { + return true; + } + } + // structs + for (size_t i = 0; i < metadata.structs.size(); ++i) + { + const SerializeMetaStruct& structSource = metadata.structs[i]; + if (structSource.type == type) + { + return true; + } + } + return false; +} + void MetaDataExchange::importMetaData(const SerializeMetaData& metadata) { // enums @@ -54,7 +77,7 @@ void MetaDataExchange::importMetaData(const SerializeMetaData& metadata) std::vector entries; for (size_t n = 0; n < enumSource.entries.size(); ++n) { - const SerializeMetaEnumEntry& entrySource = enumSource.entries[i]; + const SerializeMetaEnumEntry& entrySource = enumSource.entries[n]; entries.push_back({entrySource.name, entrySource.id, entrySource.desc, entrySource.alias}); } std::string type; @@ -73,12 +96,23 @@ void MetaDataExchange::importMetaData(const SerializeMetaData& metadata) std::vector fields; for (size_t n = 0; n < structSource.fields.size(); ++n) { - const SerializeMetaField& fieldSource = structSource.fields[i]; + const SerializeMetaField& fieldSource = structSource.fields[n]; int flags = 0; std::for_each(fieldSource.flags.begin(), fieldSource.flags.end(), [&flags] (const SerializeMetaFieldFlags& flag) { flags |= flag; }); - fields.push_back({convert(fieldSource.tid), fieldSource.type, fieldSource.name, fieldSource.desc, flags, fieldSource.attrs, -1}); + + std::string typeWithNamespace; + if (fieldSource.type.find_first_of('.') != std::string::npos || metadata.namespace_.empty() || !isInData(metadata, fieldSource.type)) + { + typeWithNamespace = fieldSource.type; + } + else + { + typeWithNamespace = metadata.namespace_ + "." + fieldSource.type; + } + + fields.push_back({convert(fieldSource.tid), typeWithNamespace, fieldSource.name, fieldSource.desc, flags, fieldSource.attrs, -1}); } int flagsStruct = 0; std::for_each(structSource.flags.begin(), structSource.flags.end(), [&flagsStruct](const SerializeMetaStructFlags& flag) { diff --git a/src/protocolsession/ProtocolSession.cpp b/src/protocolsession/ProtocolSession.cpp index 650cdbee..e15aebb0 100644 --- a/src/protocolsession/ProtocolSession.cpp +++ b/src/protocolsession/ProtocolSession.cpp @@ -260,7 +260,11 @@ void ProtocolSession::getProtocolFromConnectionId(IProtocolPtr& protocol, std::i { // mutext is already locked - IStreamConnectionPtr connection = protocol->getConnection(); + IStreamConnectionPtr connection; + if (protocol != nullptr) + { + connection = protocol->getConnection(); + } if (protocol == nullptr || (connectionId != 0 && (connection == nullptr || connectionId != connection->getConnectionId()))) { protocol = nullptr; diff --git a/src/remoteentity/RemoteEntityFormatHl7.cpp b/src/remoteentity/RemoteEntityFormatHl7.cpp index 1d7aef4f..42b41808 100644 --- a/src/remoteentity/RemoteEntityFormatHl7.cpp +++ b/src/remoteentity/RemoteEntityFormatHl7.cpp @@ -223,7 +223,7 @@ void RemoteEntityFormatHl7::serializeData(const IProtocolSessionPtr& session, IM char* payload = messageToSerialize.addSendPayload(rawData->size()); memcpy(payload, rawData->data(), rawData->size()); } - else + else if (structBase->getStructInfo().getTypeName() != finalmq::RawDataMessage::structInfo().getTypeName()) { SerializerHl7 serializerData(messageToSerialize, 512); ParserStruct parserData(serializerData, *structBase); diff --git a/src/remoteentity/RemoteEntityFormatJson.cpp b/src/remoteentity/RemoteEntityFormatJson.cpp index 9200d8e4..0637bedf 100644 --- a/src/remoteentity/RemoteEntityFormatJson.cpp +++ b/src/remoteentity/RemoteEntityFormatJson.cpp @@ -99,7 +99,7 @@ void RemoteEntityFormatJson::serializeData(const IProtocolSessionPtr& session, I char* payload = message.addSendPayload(rawData->size()); memcpy(payload, rawData->data(), rawData->size()); } - else + else if (structBase->getStructInfo().getTypeName() != finalmq::RawDataMessage::structInfo().getTypeName()) { bool enumAsString = true; bool skipDefaultValues = false; diff --git a/src/remoteentity/RemoteEntityFormatProto.cpp b/src/remoteentity/RemoteEntityFormatProto.cpp index dcd029ab..81f0e2ea 100644 --- a/src/remoteentity/RemoteEntityFormatProto.cpp +++ b/src/remoteentity/RemoteEntityFormatProto.cpp @@ -97,7 +97,7 @@ void RemoteEntityFormatProto::serializeData(const IProtocolSessionPtr& /*session char* payload = message.addSendPayload(rawData->size()); memcpy(payload, rawData->data(), rawData->size()); } - else + else if (structBase->getStructInfo().getTypeName() != finalmq::RawDataMessage::structInfo().getTypeName()) { SerializerProto serializerData(message); ParserStruct parserData(serializerData, *structBase);