diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2020-03-14 22:43:44 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2020-03-23 21:37:30 +0100 |
commit | 29ade9784fe65ecd686b5e8e18d84e6acc30b37a (patch) | |
tree | 6cb1b29880701b1f1093e9f22525678b39449baf /src/message.h | |
parent | 3357cbc91e7ff4d0d455c88785fc455067b34820 (diff) |
Direct message service
Diffstat (limited to 'src/message.h')
-rw-r--r-- | src/message.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/message.h b/src/message.h new file mode 100644 index 0000000..48487ba --- /dev/null +++ b/src/message.h @@ -0,0 +1,57 @@ +#pragma once + +#include <erebos/identity.h> +#include <erebos/message.h> +#include <erebos/storage.h> + +#include <mutex> +#include <vector> + +namespace chrono = std::chrono; +using chrono::system_clock; +using std::mutex; +using std::optional; +using std::string; +using std::vector; + +namespace erebos { + +struct DirectMessageData +{ + static optional<DirectMessageData> load(const Ref &); + Ref store(const Storage &) const; + + vector<Stored<DirectMessageData>> prev; + Identity from; + ZonedTime time; + string text; +}; + +struct DirectMessage::Priv +{ + Stored<DirectMessageData> data; +}; + +struct DirectMessageThread::Priv +{ + const Identity peer; + const vector<Stored<DirectMessageData>> head; + + static DirectMessageThread getThreadLocked(const Identity & peer); + static DirectMessageThread updateThreadLocked(const Identity & peer, + vector<Stored<DirectMessageData>> && head); +}; + +struct DirectMessageThread::Iterator::Priv +{ + optional<DirectMessage> current; + vector<Stored<DirectMessageData>> next; +}; + +struct DirectMessageService::Priv +{ + static vector<ThreadWatcher> watchers; + static mutex watcherLock; +}; + +} |