Chatterino
SeventvEventAPISubscription.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <magic_enum.hpp>
4 
5 #include <QByteArray>
6 #include <QHash>
7 #include <QString>
8 
9 namespace chatterino {
10 
11 // https://github.com/SevenTV/EventAPI/tree/ca4ff15cc42b89560fa661a76c5849047763d334#subscription-types
14  UpdateUser,
15 
16  INVALID,
17 };
18 
19 // https://github.com/SevenTV/EventAPI/tree/ca4ff15cc42b89560fa661a76c5849047763d334#opcodes
21  Dispatch = 0,
22  Hello = 1,
23  Heartbeat = 2,
24  Reconnect = 4,
25  Ack = 5,
26  Error = 6,
27  EndOfStream = 7,
28  Identify = 33,
29  Resume = 34,
30  Subscribe = 35,
31  Unsubscribe = 36,
32  Signal = 37,
33 };
34 
36  bool operator==(const SeventvEventAPISubscription &rhs) const;
37  bool operator!=(const SeventvEventAPISubscription &rhs) const;
38  QString condition;
40 
41  QByteArray encodeSubscribe() const;
42  QByteArray encodeUnsubscribe() const;
43 
44  friend QDebug &operator<<(QDebug &dbg,
45  const SeventvEventAPISubscription &subscription);
46 };
47 
48 } // namespace chatterino
49 
50 template <>
51 constexpr magic_enum::customize::customize_t magic_enum::customize::enum_name<
54 {
55  switch (value)
56  {
58  return "emote_set.update";
60  return "user.update";
61 
62  default:
63  return default_tag;
64  }
65 }
66 
67 namespace std {
68 
69 template <>
70 struct hash<chatterino::SeventvEventAPISubscription> {
72  {
73  return (size_t)qHash(sub.condition, qHash((int)sub.type));
74  }
75 };
76 
77 } // namespace std
SeventvEventAPISubscriptionType type
Definition: SeventvEventAPISubscription.hpp:39
uint qHash(const QColor &key)
Definition: ColorProvider.hpp:63
Definition: SeventvEventAPISubscription.hpp:67
Definition: Application.cpp:48
Definition: SeventvEventAPISubscription.hpp:35
size_t operator()(const chatterino::SeventvEventAPISubscription &sub) const
Definition: SeventvEventAPISubscription.hpp:71
QDebug & operator<<(QDebug &dbg, const SeventvEventAPISubscription &subscription)
Definition: SeventvEventAPISubscription.cpp:70
bool operator==(const Emote &a, const Emote &b)
Definition: Emote.cpp:7
QString condition
Definition: SeventvEventAPISubscription.hpp:38
SeventvEventAPIOpcode
Definition: SeventvEventAPISubscription.hpp:20
bool operator!=(const Emote &a, const Emote &b)
Definition: Emote.cpp:13
SeventvEventAPISubscriptionType
Definition: SeventvEventAPISubscription.hpp:12