28 #ifndef WEBSOCKETPP_TRANSPORT_ASIO_BASE_HPP
29 #define WEBSOCKETPP_TRANSPORT_ASIO_BASE_HPP
31 #include <websocketpp/common/cpp11.hpp>
32 #include <websocketpp/common/functional.hpp>
33 #include <websocketpp/common/system_error.hpp>
35 #include <boost/system/error_code.hpp>
37 #include <boost/aligned_storage.hpp>
38 #include <boost/noncopyable.hpp>
39 #include <boost/array.hpp>
59 :
private boost::noncopyable
67 void* allocate(std::size_t size)
69 if (!in_use_ && size < storage_.size)
72 return storage_.address();
76 return ::operator
new(size);
80 void deallocate(
void* pointer)
82 if (pointer == storage_.address())
88 ::operator
delete(pointer);
94 boost::aligned_storage<1024> storage_;
103 template <
typename Handler>
113 template <
typename Arg1>
114 void operator()(Arg1 arg1)
119 template <
typename Arg1,
typename Arg2>
120 void operator()(Arg1 arg1, Arg2 arg2)
122 handler_(arg1, arg2);
125 friend void* asio_handler_allocate(std::size_t size,
128 return this_handler->allocator_.allocate(size);
131 friend void asio_handler_deallocate(
void* pointer, std::size_t ,
134 this_handler->allocator_.deallocate(pointer);
143 template <
typename Handler>
158 template <
typename config>
161 typedef lib::function<void(boost::system::error_code const &)>
162 socket_shutdown_handler;
164 typedef lib::function<void (boost::system::error_code
const & ec,
165 size_t bytes_transferred)> async_read_handler;
167 typedef lib::function<void (boost::system::error_code
const & ec,
168 size_t bytes_transferred)> async_write_handler;
170 typedef lib::function<void (lib::error_code const & ec)> pre_init_handler;
205 char const * name()
const _WEBSOCKETPP_NOEXCEPT_TOKEN_ {
206 return "websocketpp.transport.asio";
209 std::string message(
int value)
const {
212 return "Generic asio transport policy error";
214 return "async_read_at_least call requested more bytes than buffer can store";
216 return "Underlying Transport Error";
218 return "Proxy connection failed";
220 return "Invalid proxy URI";
222 return "Invalid host or service";
237 return lib::error_code(static_cast<int>(e),
get_category());
245 _WEBSOCKETPP_ERROR_CODE_ENUM_NS_START_
248 static bool const value =
true;
250 _WEBSOCKETPP_ERROR_CODE_ENUM_NS_END_
251 #endif // WEBSOCKETPP_TRANSPORT_ASIO_HPP
uint16_t value
The type of a close code value.
lib::error_code make_error_code(error::value e)
Create an error code with the given value and the asio transport category.
async_read_at_least call requested more bytes than buffer can store
Asio transport error category.
there was an error in the underlying transport library
Namespace for the WebSocket++ project.
Boost Asio based endpoint transport component.
The connection to the requested proxy server failed.
lib::error_category const & get_category()
Get a reference to a static copy of the asio transport error category.