SuperTuxKart
Loading...
Searching...
No Matches
rich_presence.hpp
1#include <atomic>
2#ifdef WIN32
3#include <namedpipeapi.h>
4#endif
5#include <thread>
6#include <map>
7
8namespace RichPresenceNS
9{
10 class AssetRequest;
11 // There are more, but we don't need to use them
12 enum OPCodes
13 {
14 OP_HANDSHAKE = 0,
15 OP_DATA = 1,
16 };
18 {
19 int32_t op;
20 int32_t length;
21 char data[];
22 };
24 {
25 private:
26 bool m_connected;
27 std::atomic_bool m_ready;
28 time_t m_last;
29#ifdef WIN32
30 HANDLE m_socket;
31#else
32 int m_socket;
33#endif
34 std::shared_ptr<AssetRequest> m_assets_request;
35 std::thread* m_thread;
36 std::map<std::string, bool> m_asset_cache;
37 std::string m_assets;
38 bool tryConnect(std::string path);
39 bool doConnect();
40 void terminate();
41 void sendData(int32_t op, std::string json);
42 void handshake();
43 void readData();
44 void ensureCache();
45 static void finishConnection(RichPresence* self);
46 public:
49 void update(bool force);
50 static RichPresence* get();
51 static void destroy();
52 };
53}
Definition: rich_presence.hpp:24
Definition: rich_presence.hpp:18