summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authortastytea2020-01-09 12:24:29 +0100
committertastytea2020-01-09 12:24:29 +0100
commitec41063488c9c043c7eb859254542d7b2a1a9f2d (patch)
tree4648e8ac6a02e1cc90b92d380dca88b6cc18d9d7 /include
parent839e29b37ba4c36579e6a73ff150115e8177bd86 (diff)
downloadmastodonpp-ec41063488c9c043c7eb859254542d7b2a1a9f2d.tar
mastodonpp-ec41063488c9c043c7eb859254542d7b2a1a9f2d.tar.gz
mastodonpp-ec41063488c9c043c7eb859254542d7b2a1a9f2d.zip
Add get_new_events().
A more comfortable way to consume stream events.
Diffstat (limited to 'include')
-rw-r--r--include/connection.hpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/connection.hpp b/include/connection.hpp
index b32acea..6885931 100644
--- a/include/connection.hpp
+++ b/include/connection.hpp
@@ -25,6 +25,7 @@
#include <string>
#include <string_view>
#include <variant>
+#include <vector>
namespace mastodonpp
{
@@ -32,6 +33,7 @@ namespace mastodonpp
using std::string;
using std::string_view;
using std::variant;
+using std::vector;
/*!
* @brief An endpoint. Either API::endpoint_type or `std::string_view`.
@@ -41,6 +43,29 @@ using std::variant;
using endpoint_variant = variant<API::endpoint_type,string_view>;
/*!
+ * @brief A stream event.
+ *
+ * @since 0.1.0
+ *
+ * @headerfile connection.hpp mastodonpp/connection.hpp
+ */
+struct event_type
+{
+ /*!
+ * @brief The type of the event.
+ *
+ * Can be: “update”, “notification”, “delete” or “filters_changed”. For
+ * more information consult [the Mastodon documentation]
+ * (https://docs.joinmastodon.org/methods/timelines/streaming/
+ * #event-types-a-idevent-typesa).
+ */
+ string type;
+
+ //! The payload.
+ string data;
+};
+
+/*!
* @brief Represents a connection to an instance. Used for requests.
*
* @since 0.1.0
@@ -106,10 +131,19 @@ public:
* that you are calling this function mid-transfer. You have to check the
* data integrity yourself.
*
+ * Using get_new_events() instead is recommended.
+ *
* @since 0.1.0
*/
string get_new_stream_contents();
+ /*!
+ * @brief Get new stream events.
+ *
+ * @since 0.1.0
+ */
+ vector<event_type> get_new_events();
+
private:
Instance &_instance;
const string_view _baseuri;