Skip to content

Commit ee6e423

Browse files
whatisorjmigual
andauthored
core: Sync session id with server (#410)
* 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]>
1 parent 1224324 commit ee6e423

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/internal/sio_client_impl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,19 @@ namespace sio
557557
{
558558
case packet::frame_message:
559559
{
560+
// Special event for sid sync
561+
if (p.get_type() == packet::type_connect) {
562+
auto message = p.get_message();
563+
if (message && message->get_flag() == message::flag_object)
564+
{
565+
const object_message* obj_ptr = static_cast<object_message*>(message.get());
566+
const std::map<std::string, message::ptr>* values = &(obj_ptr->get_map());
567+
auto it = values->find("sid");
568+
if (it != values->end()) {
569+
m_sid = std::static_pointer_cast<string_message>(it->second)->get_string();
570+
}
571+
}
572+
}
560573
socket::ptr so_ptr = get_socket_locked(p.get_nsp());
561574
if(so_ptr)so_ptr->on_message_packet(p);
562575
break;

0 commit comments

Comments
 (0)