<divclass="fragment"><divclass="line"><spanclass="comment">/* This file is part of mastodon-cpp.</span></div><divclass="line"><spanclass="comment"> * Prints some information from the public timeline.</span></div><divclass="line"><spanclass="comment"> */</span></div><divclass="line"></div><divclass="line"><spanclass="comment">// Don't compile this if the Easy-interface is turned off</span></div><divclass="line"><spanclass="preprocessor">#ifndef WITHOUT_EASY</span></div><divclass="line"></div><divclass="line"><spanclass="preprocessor">#include <iostream></span></div><divclass="line"><spanclass="preprocessor">#include <string></span></div><divclass="line"><spanclass="preprocessor">#include <thread></span></div><divclass="line"><spanclass="preprocessor">#include <memory></span></div><divclass="line"><spanclass="preprocessor">#include <vector></span></div><divclass="line"><spanclass="preprocessor">#include <chrono></span></div><divclass="line"><spanclass="preprocessor">#include <mutex></span></div><divclass="line"></div><divclass="line"><spanclass="comment">// If we are compiling mastodon-cpp, use another include path</span></div><divclass="line"><spanclass="preprocessor">#ifdef MASTODON_CPP</span></div><divclass="line"><spanclass="preprocessor"> #include "mastodon-cpp.hpp"</span></div><divclass="line"><spanclass="preprocessor"> #include "easy/all.hpp"</span></div><divclass="line"><spanclass="preprocessor">#else</span></div><divclass="line"><spanclass="preprocessor"> #include <mastodon-cpp/mastodon-cpp.hpp></span></div><divclass="line"><spanclass="comment">// Include all headers in mastodon-cpp/easy/</span></div><divclass="line"><spanclass="preprocessor"> #include <mastodon-cpp/easy/all.hpp></span></div><divclass="line"><spanclass="preprocessor">#endif</span></div><divclass="line"></div><divclass="line"><spanclass="keyword">using</span><aname="_a0"></a><aclass="code"href="classMastodon_1_1API.html">Mastodon::API</a>;</div><divclass="line"><spanclass="keyword">using</span><aname="_a1"></a><aclass="code"href="classMastodon_1_1Easy.html">Mastodon::Easy</a>;</div><divclass="line"><spanclass="keyword">using</span> std::cout;</div><divclass="line"><spanclass="keyword">using</span> std::chrono::system_clock;</div><divclass="line"></div><divclass="line"><spanclass="keywordtype">int</span> main(<spanclass="keywordtype">int</span> argc, <spanclass="keywordtype">char</span> *argv[])</div><divclass="line">{</div><divclass="line"><spanclass="keywordflow">if</span> (argc < 3)</div><divclass="line"> {</div><divclass="line"> std::cerr <<<spanclass="stringliteral">"usage: "</span><< argv[0] <<<spanclass="stringliteral">"<instance><access token>\n"</span>;</div><divclass="line"><spanclass="keywordflow">return</span> 1;</div><divclass="line"> }</div><divclass="line"></div><divclass="line"> cout <<<spanclass="stringliteral">"I'll show you the public timeline. Press CTRL-C to cancel\n"</span>;</div><divclass="line"></div><divclass="line"><spanclass="comment">// These have to be static in order to use them in- and outside the thread</span></div><divclass="line"><spanclass="keyword">static</span> std::string stream;</div><divclass="line"><spanclass="comment">// You can cancel the stream with this pointer (ptr->cancel_stream())</span></div><divclass="line"><spanclass="keyword">static</span> std::unique_ptr<Mastodon::API::http> ptr;</div><divclass="line"></div><divclass="line"><spanclass="comment">// Start a new thread for the stream</span></div><divclass="line"> std::thread pub_tl([=]</div><divclass="line"> {</div><divclass="line"> Easy masto(argv[1], argv[2]);</div><divclass="line"> masto.get_stream(Mastodon::API::v1::streaming_public, stream, ptr);</div><divclass="line"> });</div><divclass="line"></
<!-- start footer part -->
<hrclass="footer"/><addressclass="footer"><small>
Generated by  <ahref="http://www.doxygen.org/index.html">