1 #ifndef CPP_WEB_SERVER_WEBSOCKET_MESSAGE_HPP 2 #define CPP_WEB_SERVER_WEBSOCKET_MESSAGE_HPP 4 #include <boost/asio.hpp> 5 #include <boost/logic/tribool.hpp> 6 #include <boost/shared_ptr.hpp> 7 #include <boost/tuple/tuple.hpp> 10 # define PACKED_STRUCT(name) \ 11 __pragma(pack(push, 1)) struct name __pragma(pack(pop)) 12 #elif defined(__GNUC__) 13 # define PACKED_STRUCT(name) struct __attribute__((packed)) name 15 # warning I don't know how to create a packed struct with your compiler 16 # define PACKED_STRUCT(name) struct name 22 class WebsocketMessage;
34 opcode_continuation = 0,
46 unsigned char len : 7;
49 static_assert(
sizeof(Header) == 2,
50 "the Header struct is not properly packed");
61 bool serialize(std::vector<unsigned char>& buffer);
70 template<
typename InputIterator>
71 boost::tuple<boost::tribool, InputIterator>
76 boost::tribool result = consume(frame, *begin++);
77 if (result || !result)
78 return boost::make_tuple(result, begin);
80 boost::tribool result = boost::indeterminate;
81 return boost::make_tuple(result, begin);
bool fromMessage(const WebsocketMessage &message)
bool serialize(std::vector< unsigned char > &buffer)
boost::tuple< boost::tribool, InputIterator > parse(WebsocketFrame &frame, InputIterator begin, InputIterator end)