Skip to content

Commit

Permalink
core: Sync session id with server (#410)
Browse files Browse the repository at this point in the history
* Sync session id with server

* Update sio_client_impl.cpp

Use `std::` when required. 

Even though there is a `using namespace std` this should be removed and we should add `std::` whenever possible

---------

Co-authored-by: Joan Marcè i Igual <[email protected]>
  • Loading branch information
whatisor and jmigual authored Nov 8, 2023
1 parent 1224324 commit ee6e423
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,19 @@ namespace sio
{
case packet::frame_message:
{
// Special event for sid sync
if (p.get_type() == packet::type_connect) {
auto message = p.get_message();
if (message && message->get_flag() == message::flag_object)
{
const object_message* obj_ptr = static_cast<object_message*>(message.get());
const std::map<std::string, message::ptr>* values = &(obj_ptr->get_map());
auto it = values->find("sid");
if (it != values->end()) {
m_sid = std::static_pointer_cast<string_message>(it->second)->get_string();
}
}
}
socket::ptr so_ptr = get_socket_locked(p.get_nsp());
if(so_ptr)so_ptr->on_message_packet(p);
break;
Expand Down

0 comments on commit ee6e423

Please sign in to comment.