#ifndef WITHOUT_EASY
#include <iostream>
#include <string>
#include <cstdint>
#include <mutex>
#include <chrono>
#include <vector>
#include "mastodon-cpp.hpp"
#include "easy/all.hpp"
using std::cout;
using std::cerr;
using std::endl;
using std::string;
using std::uint8_t;
int main(int argc, char *argv[])
{
if (argc < 2)
{
std::cerr << "usage: " << argv[0] << " <instance>\n";
return 1;
}
std::unique_ptr<API::http> ptr;
string stream;
masto.
get_stream(API::v1::streaming_public, ptr, stream);
for (uint8_t counter = 0; counter < 120; ++counter)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::lock_guard<std::mutex> lock(ptr->get_mutex());
std::vector<Easy::stream_event_type> events
stream.clear();
{
switch (event.type)
{
case Easy::event_type::Update:
{
<<
" (" << status.
url() <<
")\n";
break;
}
case Easy::event_type::Notification:
{
cout << "Notification involving: "
<<
" (" << notification.
id() <<
")\n";
break;
}
case Easy::event_type::Delete:
{
cout << "Deleted: " << event.data << endl;
break;
}
case Easy::event_type::Error:
{
cerr << "Error: " << event.data << endl;
ptr->cancel_stream();
return 1;
}
default:
{
cout << "Something undefined happened. 😱\n";
cout << event.data << endl;
}
}
}
}
ptr->cancel_stream();
return 0;
}
#else
#include <cstdio>
int main()
{
std::printf("mastodon-cpp was compiled without Easy support.\n");
return 255;
}
#endif // WITHOUT_EASY