mirror of
https://github.com/socketio/socket.io-client-cpp.git
synced 2026-06-09 19:54:46 +00:00
breaking change of ack callback, windows compile fix for PR
This commit is contained in:
parent
9e9d76c089
commit
7a3933e333
@ -11,6 +11,7 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
#include <type_traits>
|
||||
namespace sio
|
||||
{
|
||||
using namespace std;
|
||||
@ -28,7 +29,7 @@ namespace sio
|
||||
flag_object
|
||||
};
|
||||
|
||||
virtual ~message() = default;
|
||||
virtual ~message(){};
|
||||
|
||||
class list;
|
||||
|
||||
@ -261,6 +262,13 @@ namespace sio
|
||||
m_vector(std::move(rhs.m_vector))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
list(T&& content,
|
||||
typename enable_if<is_same<vector<message::ptr>,typename remove_reference<T>::type>::value>::type* = 0):
|
||||
m_vector(std::forward<T>(content))
|
||||
{
|
||||
}
|
||||
|
||||
list(message::list const& rhs):
|
||||
|
||||
@ -131,7 +131,7 @@ namespace sio
|
||||
|
||||
void close();
|
||||
|
||||
void emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack);
|
||||
void emit(std::string const& name, message::list const& msglist, std::function<void (message::list const&)> const& ack);
|
||||
|
||||
std::string const& get_namespace() const {return m_nsp;}
|
||||
|
||||
@ -150,7 +150,7 @@ namespace sio
|
||||
|
||||
// Message Parsing callbacks.
|
||||
void on_socketio_event(const std::string& nsp, int msgId,const std::string& name, message::list&& message);
|
||||
void on_socketio_ack(int msgId, message::ptr const& message);
|
||||
void on_socketio_ack(int msgId, message::list const& message);
|
||||
void on_socketio_error(message::ptr const& err_message);
|
||||
|
||||
event_listener get_bind_listener_locked(string const& event);
|
||||
@ -172,7 +172,7 @@ namespace sio
|
||||
bool m_connected;
|
||||
std::string m_nsp;
|
||||
|
||||
std::map<unsigned int, std::function<void (message::ptr const&)> > m_acks;
|
||||
std::map<unsigned int, std::function<void (message::list const&)> > m_acks;
|
||||
|
||||
std::map<std::string, event_listener> m_event_binding;
|
||||
|
||||
@ -243,7 +243,7 @@ namespace sio
|
||||
|
||||
unsigned int socket::impl::s_global_event_id = 1;
|
||||
|
||||
void socket::impl::emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack)
|
||||
void socket::impl::emit(std::string const& name, message::list const& msglist, std::function<void (message::list const&)> const& ack)
|
||||
{
|
||||
NULL_GUARD(m_client);
|
||||
message::ptr msg_ptr = msglist.to_array_message(name);
|
||||
@ -398,19 +398,13 @@ namespace sio
|
||||
const message::ptr ptr = p.get_message();
|
||||
if(ptr->get_flag() == message::flag_array)
|
||||
{
|
||||
const array_message* array_ptr = static_cast<const array_message*>(ptr.get());
|
||||
if(array_ptr->get_vector().size() >= 1&&array_ptr->get_vector()[0]->get_flag() == message::flag_string)
|
||||
{
|
||||
message::ptr value_ptr;
|
||||
if(array_ptr->get_vector().size()>1)
|
||||
{
|
||||
value_ptr = array_ptr->get_vector()[1];
|
||||
}
|
||||
this->on_socketio_ack(p.get_pack_id(), value_ptr);
|
||||
break;
|
||||
}
|
||||
message::list msglist(ptr->get_vector());
|
||||
this->on_socketio_ack(p.get_pack_id(),msglist);
|
||||
}
|
||||
this->on_socketio_ack(p.get_pack_id(),ptr);
|
||||
else
|
||||
{
|
||||
this->on_socketio_ack(p.get_pack_id(),message::list(ptr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Error
|
||||
@ -445,9 +439,9 @@ namespace sio
|
||||
send_packet(p);
|
||||
}
|
||||
|
||||
void socket::impl::on_socketio_ack(int msgId, message::ptr const& message)
|
||||
void socket::impl::on_socketio_ack(int msgId, message::list const& message)
|
||||
{
|
||||
std::function<void (message::ptr const&)> l;
|
||||
std::function<void (message::list const&)> l;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_event_mutex);
|
||||
auto it = m_acks.find(msgId);
|
||||
@ -551,7 +545,7 @@ namespace sio
|
||||
m_impl->off_error();
|
||||
}
|
||||
|
||||
void socket::emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack)
|
||||
void socket::emit(std::string const& name, message::list const& msglist, std::function<void (message::list const&)> const& ack)
|
||||
{
|
||||
m_impl->emit(name, msglist,ack);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ namespace sio
|
||||
|
||||
void off_error();
|
||||
|
||||
void emit(std::string const& name, message::list const& msglist = nullptr, std::function<void (message::ptr const&)> const& ack = nullptr);
|
||||
void emit(std::string const& name, message::list const& msglist = nullptr, std::function<void (message::list const&)> const& ack = nullptr);
|
||||
|
||||
std::string const& get_namespace() const;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user