Skip to content

Commit

Permalink
refactor: ♻️ add constructor for easier emplace
Browse files Browse the repository at this point in the history
  • Loading branch information
Xminent committed Dec 27, 2023
1 parent 4115b97 commit 01b4f95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion include/ekizu/shard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ struct Shard {

private:
struct Session {
std::string id{};
Session(std::string_view id_, uint64_t sequence_)
: id{id_}, sequence{sequence_} {}

std::string id;
uint64_t sequence{};
};

Expand Down
5 changes: 2 additions & 3 deletions src/shard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,9 @@ Result<Event> Shard::handle_dispatch(const nlohmann::json &data) {
return boost::system::errc::invalid_argument;
}

m_session.emplace();
m_session.emplace(
event["session_id"].get<std::string>(), sequence.value_or(0));
m_resume_gateway_url = event["resume_gateway_url"].get<std::string>();
m_session->id = event["session_id"];
m_session->sequence = sequence.value_or(0);

log(fmt::format("received ready | resume_gateway_url={}, session_id={}",
*m_resume_gateway_url, m_session->id));
Expand Down

0 comments on commit 01b4f95

Please sign in to comment.