|
4 | 4 | #include <boost/asio/deadline_timer.hpp> |
5 | 5 | #include <boost/system/error_code.hpp> |
6 | 6 | #include <queue> |
| 7 | +#include <cstdarg> |
7 | 8 |
|
8 | 9 | #if DEBUG || _DEBUG |
9 | 10 | #define LOG(x) std::cout << x |
@@ -114,17 +115,7 @@ void set_##__FIELD__(__TYPE__ const& l) \ |
114 | 115 |
|
115 | 116 | void close(); |
116 | 117 |
|
117 | | - void emit(std::string const& name, std::string const& message); |
118 | | - |
119 | | - void emit(std::string const& name, std::string const& message, std::function<void (message::ptr const&)> const& ack); |
120 | | - |
121 | | - void emit(std::string const& name, message::ptr const& args); |
122 | | - |
123 | | - void emit(std::string const& name, message::ptr const& args, std::function<void (message::ptr const&)> const& ack); |
124 | | - |
125 | | - void emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr); |
126 | | - |
127 | | - void emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr, std::function<void (message::ptr const&)> const& ack); |
| 118 | + void emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack); |
128 | 119 |
|
129 | 120 | std::string const& get_namespace() const {return m_nsp;} |
130 | 121 |
|
@@ -236,59 +227,12 @@ void set_##__FIELD__(__TYPE__ const& l) \ |
236 | 227 |
|
237 | 228 | unsigned int socket::impl::s_global_event_id = 1; |
238 | 229 |
|
239 | | - void socket::impl::emit(std::string const& name, std::string const& message) |
240 | | - { |
241 | | - NULL_GUARD(m_client); |
242 | | - message::ptr msg_ptr = make_message(name, message); |
243 | | - packet p(m_nsp, msg_ptr); |
244 | | - __send_packet(p); |
245 | | - } |
246 | | - |
247 | | - void socket::impl::emit(std::string const& name, std::string const& message, std::function<void (message::ptr const&)> const& ack) |
248 | | - { |
249 | | - NULL_GUARD(m_client); |
250 | | - message::ptr msg_ptr = make_message(name, message); |
251 | | - packet p(m_nsp, msg_ptr,s_global_event_id); |
252 | | - { |
253 | | - std::lock_guard<std::mutex> guard(m_event_mutex); |
254 | | - m_acks[s_global_event_id++] = ack; |
255 | | - } |
256 | | - __send_packet(p); |
257 | | - } |
258 | | - |
259 | | - void socket::impl::emit(std::string const& name, message::ptr const& args) |
260 | | - { |
261 | | - NULL_GUARD(m_client); |
262 | | - message::ptr msg_ptr = make_message(name, args); |
263 | | - packet p(m_nsp, msg_ptr); |
264 | | - __send_packet(p); |
265 | | - } |
266 | | - |
267 | | - void socket::impl::emit(std::string const& name, message::ptr const& args, std::function<void (message::ptr const&)> const& ack) |
| 230 | + void socket::impl::emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack) |
268 | 231 | { |
269 | 232 | NULL_GUARD(m_client); |
270 | | - message::ptr msg_ptr = make_message(name, args); |
271 | | - packet p(m_nsp, msg_ptr,s_global_event_id); |
272 | | - { |
273 | | - std::lock_guard<std::mutex> guard(m_event_mutex); |
274 | | - m_acks[s_global_event_id++] = ack; |
275 | | - } |
276 | | - __send_packet(p); |
277 | | - } |
278 | | - |
279 | | - void socket::impl::emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr) |
280 | | - { |
281 | | - NULL_GUARD(m_client); |
282 | | - message::ptr msg_ptr = make_message(name, binary_ptr); |
283 | | - packet p(m_nsp, msg_ptr); |
284 | | - __send_packet(p); |
285 | | - } |
286 | | - |
287 | | - void socket::impl::emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr, std::function<void (message::ptr const&)> const& ack) |
288 | | - { |
289 | | - NULL_GUARD(m_client); |
290 | | - message::ptr msg_ptr = make_message(name, binary_ptr); |
| 233 | + message::ptr msg_ptr = msglist.to_array_message(name); |
291 | 234 | packet p(m_nsp, msg_ptr,s_global_event_id); |
| 235 | + if(ack) |
292 | 236 | { |
293 | 237 | std::lock_guard<std::mutex> guard(m_event_mutex); |
294 | 238 | m_acks[s_global_event_id++] = ack; |
@@ -579,41 +523,16 @@ void set_##__FIELD__(__TYPE__ const& l) \ |
579 | 523 | m_impl->off_error(); |
580 | 524 | } |
581 | 525 |
|
582 | | - void socket::emit(std::string const& name, std::string const& message) |
| 526 | + void socket::emit(std::string const& name, message::list const& msglist, std::function<void (message::ptr const&)> const& ack) |
583 | 527 | { |
584 | | - m_impl->emit(name, message); |
585 | | - } |
586 | | - |
587 | | - void socket::emit(std::string const& name, std::string const& message, std::function<void (message::ptr const&)> const& ack) |
588 | | - { |
589 | | - m_impl->emit(name, message,ack); |
590 | | - } |
591 | | - |
592 | | - void socket::emit(std::string const& name, message::ptr const& args) |
593 | | - { |
594 | | - m_impl->emit(name, args); |
595 | | - } |
596 | | - |
597 | | - void socket::emit(std::string const& name, message::ptr const& args, std::function<void (message::ptr const&)> const& ack) |
598 | | - { |
599 | | - m_impl->emit(name, args,ack); |
600 | | - } |
601 | | - |
602 | | - void socket::emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr){ |
603 | | - m_impl->emit(name, binary_ptr); |
604 | | - } |
605 | | - |
606 | | - void socket::emit(std::string const& name, std::shared_ptr<const std::string> const& binary_ptr, std::function<void (message::ptr const&)> const& ack) |
607 | | - { |
608 | | - m_impl->emit(name, binary_ptr,ack); |
| 528 | + m_impl->emit(name, msglist,ack); |
609 | 529 | } |
610 | 530 |
|
611 | 531 | std::string const& socket::get_namespace() const |
612 | 532 | { |
613 | 533 | return m_impl->get_namespace(); |
614 | 534 | } |
615 | 535 |
|
616 | | - |
617 | 536 | void socket::on_connected() |
618 | 537 | { |
619 | 538 | m_impl->on_connected(); |
|
0 commit comments