2023-07-30 13:14:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
class QByteArray;
|
|
|
|
class QString;
|
|
|
|
|
2024-03-03 13:15:50 +01:00
|
|
|
namespace chatterino {
|
|
|
|
|
|
|
|
class Paths;
|
|
|
|
|
|
|
|
} // namespace chatterino
|
|
|
|
|
2023-07-30 13:14:58 +02:00
|
|
|
namespace chatterino::ipc {
|
|
|
|
|
2024-03-03 13:15:50 +01:00
|
|
|
void initPaths(const Paths *paths);
|
|
|
|
|
2023-07-30 13:14:58 +02:00
|
|
|
void sendMessage(const char *name, const QByteArray &data);
|
|
|
|
|
|
|
|
class IpcQueuePrivate;
|
|
|
|
class IpcQueue
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~IpcQueue();
|
|
|
|
|
|
|
|
static std::pair<std::unique_ptr<IpcQueue>, QString> tryReplaceOrCreate(
|
|
|
|
const char *name, size_t maxMessages, size_t maxMessageSize);
|
|
|
|
|
|
|
|
// TODO: use std::expected
|
|
|
|
/// Try to receive a message.
|
|
|
|
/// In the case of an error, the buffer is empty.
|
|
|
|
QByteArray receive();
|
|
|
|
|
|
|
|
private:
|
|
|
|
IpcQueue(IpcQueuePrivate *priv);
|
|
|
|
|
|
|
|
std::unique_ptr<IpcQueuePrivate> private_;
|
|
|
|
|
|
|
|
friend class IpcQueuePrivate;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino::ipc
|