fished base communication between browser and chatterino
This commit is contained in:
@@ -114,12 +114,8 @@ void runNativeMessagingHost()
|
||||
std::cin.read(b, size);
|
||||
*(b + size) = '\0';
|
||||
|
||||
nmm.writeByteArray("{\"a\":1}");
|
||||
|
||||
nmm.sendToGuiProcess(QByteArray(b, size));
|
||||
|
||||
nmm.writeByteArray("{\"a\":2}");
|
||||
|
||||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +95,7 @@ void NativeMessagingManager::openGuiMessageQueue()
|
||||
void NativeMessagingManager::sendToGuiProcess(const QByteArray &array)
|
||||
{
|
||||
#ifdef BOOSTLIBS
|
||||
writeByteArray("{\"b\": 1}");
|
||||
ipc::message_queue messageQueue(ipc::open_or_create, "chatterino_gui", 100, MESSAGE_SIZE);
|
||||
writeByteArray("{\"b\": 2}");
|
||||
|
||||
try {
|
||||
messageQueue.try_send(array.data(), array.size(), 1);
|
||||
@@ -122,13 +120,20 @@ void NativeMessagingManager::ReceiverThread::run()
|
||||
|
||||
messageQueue.receive(buf, MESSAGE_SIZE, retSize, priority);
|
||||
|
||||
QString text = QString::fromUtf8(buf, retSize);
|
||||
qDebug() << text;
|
||||
QJsonDocument document = QJsonDocument::fromRawData(buf, retSize);
|
||||
|
||||
this->handleMessage(document.object());
|
||||
} catch (ipc::interprocess_exception &ex) {
|
||||
qDebug() << "received from gui process:" << ex.what();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &root)
|
||||
{
|
||||
// TODO: add code xD
|
||||
}
|
||||
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -16,6 +16,9 @@ public:
|
||||
{
|
||||
public:
|
||||
void run() override;
|
||||
|
||||
private:
|
||||
void handleMessage(const QJsonObject &root);
|
||||
};
|
||||
|
||||
void writeByteArray(QByteArray a);
|
||||
|
||||
Reference in New Issue
Block a user