Skip to content

Commit

Permalink
Move flatbuffer server to separate thread
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev committed Feb 27, 2022
1 parent f426758 commit ead6db4
Show file tree
Hide file tree
Showing 9 changed files with 594 additions and 477 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 awawa-dev
Copyright (c) 2022 awawa-dev

Project homesite: https://github.com/awawa-dev/HyperHDR

Expand Down
9 changes: 7 additions & 2 deletions assets/webconfig/js/hyperhdr.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,13 @@ function initWebSocket()
if (tan != -1)
{
var error = response.hasOwnProperty("error") ? response.error : "unknown";
$(window.hyperhdr).trigger({ type: "error", reason: error });
console.log("[window.websocket::onmessage] ", error);

if (error == "Not ready")
window.location.reload();
else
$(window.hyperhdr).trigger({ type: "error", reason: error });

console.log("[window.websocket::onmessage] ", error);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions include/flatbufserver/FlatBufferConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class FlatBufferConnection : public QObject
///
void sendMessage(const uint8_t* buffer, uint32_t size);

bool isFree();

public slots:
///
/// @brief Set the leds according to the given image
Expand Down Expand Up @@ -135,6 +133,7 @@ private slots:
Logger* _log;
flatbuffers::FlatBufferBuilder _builder;

bool _registered;
bool _free;
bool _registered;
bool _sent;
uint64_t _lastSendImage;
};
4 changes: 2 additions & 2 deletions include/hyperhdrbase/HyperHdrInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ class HyperHdrInstance : public QObject
///
QString getActiveDeviceType() const;

bool getReadOnlyMode() { return _readOnlyMode; };

ImageProcessor* getImageProcessor();

public slots:

bool getReadOnlyMode() { return _readOnlyMode; };

void saveCalibration(QString saveData);

///
Expand Down
31 changes: 28 additions & 3 deletions include/hyperhdrbase/MessageForwarder.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
class HyperHdrInstance;
class QTcpSocket;
class FlatBufferConnection;
class MessageForwarderHelper;

class MessageForwarder : public QObject
{
Expand Down Expand Up @@ -93,11 +94,35 @@ private slots:
QStringList _jsonSlaves;

/// Proto connection for forwarding
QStringList _flatSlaves;
QList<FlatBufferConnection*> _forwardClients;
QStringList _flatSlaves;

/// Flag if forwarder is enabled
bool _forwarder_enabled = true;

const int _priority;
const int _priority;

MessageForwarderHelper* _messageForwarderHelper;
};

class MessageForwarderHelper : public QObject
{
Q_OBJECT

QList<FlatBufferConnection*> _forwardClients;
bool _free;

public:
MessageForwarderHelper();

~MessageForwarderHelper();

signals:
void addClient(const QString& origin, const QString& address, int priority, bool skipReply);
void clearClients();

public slots:
bool isFree();
void forwardImage(const Image<ColorRgb>& image);
void addClientHandler(const QString& origin, const QString& address, int priority, bool skipReply);
void clearClientsHandler();
};

0 comments on commit ead6db4

Please sign in to comment.