Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
beckdave committed Jan 10, 2024
1 parent fd6af08 commit 2d8efd7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 13 deletions.
8 changes: 4 additions & 4 deletions codegenerator/cpp/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
16 changes: 14 additions & 2 deletions htdocs/fmq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
1 change: 1 addition & 0 deletions inc/finalmq/metadataserialize/MetaDataExchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
40 changes: 37 additions & 3 deletions src/metadataserialize/MetaDataExchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,29 @@ static SerializeMetaTypeId convert(MetaTypeId value)
return static_cast<SerializeMetaTypeId::Enum>(static_cast<MetaTypeId>(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
Expand All @@ -54,7 +77,7 @@ void MetaDataExchange::importMetaData(const SerializeMetaData& metadata)
std::vector<MetaEnumEntry> 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;
Expand All @@ -73,12 +96,23 @@ void MetaDataExchange::importMetaData(const SerializeMetaData& metadata)
std::vector<MetaField> 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) {
Expand Down
6 changes: 5 additions & 1 deletion src/protocolsession/ProtocolSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/remoteentity/RemoteEntityFormatHl7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/remoteentity/RemoteEntityFormatJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/remoteentity/RemoteEntityFormatProto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2d8efd7

Please sign in to comment.