fill out gateway op enum using internal names

This commit is contained in:
ouwou 2022-03-03 03:01:09 -05:00
parent fc3d0fddd2
commit 17f1289c84
3 changed files with 25 additions and 6 deletions

View File

@ -1328,7 +1328,7 @@ void DiscordClient::HandleGatewayMessage(std::string str) {
case GatewayOp::InvalidSession: {
HandleGatewayInvalidSession(m);
} break;
case GatewayOp::Event: {
case GatewayOp::Dispatch: {
auto iter = m_event_map.find(m.Type);
if (iter == m_event_map.end()) {
printf("Unknown event %s\n", m.Type.c_str());

View File

@ -77,7 +77,7 @@ void from_json(const nlohmann::json &j, GuildMemberListUpdateMessage &m) {
}
void to_json(nlohmann::json &j, const LazyLoadRequestMessage &m) {
j["op"] = GatewayOp::LazyLoadRequest;
j["op"] = GatewayOp::GuildSubscriptions;
j["d"] = nlohmann::json::object();
j["d"]["guild_id"] = m.GuildID;
if (m.Channels.has_value()) {
@ -98,7 +98,7 @@ void to_json(nlohmann::json &j, const LazyLoadRequestMessage &m) {
}
void to_json(nlohmann::json &j, const UpdateStatusMessage &m) {
j["op"] = GatewayOp::UpdateStatus;
j["op"] = GatewayOp::PresenceUpdate;
j["d"] = nlohmann::json::object();
j["d"]["since"] = m.Since;
j["d"]["activities"] = m.Activities;

View File

@ -24,16 +24,35 @@
// most stuff below should just be objects that get processed and thrown away immediately
enum class GatewayOp : int {
Event = 0,
Dispatch = 0,
Heartbeat = 1,
Identify = 2,
UpdateStatus = 3,
PresenceUpdate = 3,
VoiceStateUpdate = 4,
VoiceServerPing = 5,
Resume = 6,
Reconnect = 7,
RequestGuildMembers = 8,
InvalidSession = 9,
Hello = 10,
HeartbeatAck = 11,
LazyLoadRequest = 14,
// 12 unused
CallConnect = 13,
GuildSubscriptions = 14,
LobbyConnect = 15,
LobbyDisconnect = 16,
LobbyVoiceStatesUpdate = 17,
StreamCreate = 18,
StreamDelete = 19,
StreamWatch = 20,
StreamPing = 21,
StreamSetPaused = 22,
// 23 unused
RequestGuildApplicationCommands = 24,
EmbeddedActivityLaunch = 25,
EmbeddedActivityClose = 26,
EmbeddedActivityUpdate = 27,
RequestForumUnreads = 28,
};
enum class GatewayEvent : int {