11 header.opcode = WebsocketFrame::Header::opcode_text;
14 header.opcode = WebsocketFrame::Header::opcode_binary;
17 header.opcode = WebsocketFrame::Header::opcode_close;
20 header.opcode = WebsocketFrame::Header::opcode_ping;
23 header.opcode = WebsocketFrame::Header::opcode_pong;
44 else if (
length <= std::numeric_limits<uint16_t>::max())
49 else if (
length <= std::numeric_limits<uint64_t>::max())
58 buffer.resize(header_size +
content.size());
66 else if (
length <= std::numeric_limits<uint16_t>::max())
68 buffer[2] = (
length >> 8) & 0xFF;
69 buffer[3] = (
length >> 0) & 0xFF;
71 else if (
length <= std::numeric_limits<uint64_t>::max())
73 buffer[2] = (
length >> 56) & 0xFF;
74 buffer[3] = (
length >> 48) & 0xFF;
75 buffer[4] = (
length >> 40) & 0xFF;
76 buffer[5] = (
length >> 32) & 0xFF;
77 buffer[6] = (
length >> 24) & 0xFF;
78 buffer[7] = (
length >> 16) & 0xFF;
79 buffer[8] = (
length >> 8) & 0xFF;
80 buffer[9] = (
length >> 0) & 0xFF;
93 state_ = header_byte1;
102 state_ = header_byte2;
103 return boost::indeterminate;
106 if (frame.
header.len < 126)
113 else if (frame.
length > 0)
118 else if (frame.
header.len == 126)
121 state_ = length_2bytes_left;
126 state_ = length_8bytes_left;
128 return boost::indeterminate;
130 case length_8bytes_left:
131 frame.
length |= ((uint64_t)(input & 0xFF) << 56);
132 state_ = length_7bytes_left;
133 return boost::indeterminate;
134 case length_7bytes_left:
135 frame.
length |= ((uint64_t)(input & 0xFF) << 48);
136 state_ = length_6bytes_left;
137 return boost::indeterminate;
138 case length_6bytes_left:
139 frame.
length |= ((uint64_t)(input & 0xFF) << 40);
140 state_ = length_5bytes_left;
141 return boost::indeterminate;
142 case length_5bytes_left:
143 frame.
length |= ((uint64_t)(input & 0xFF) << 32);
144 state_ = length_4bytes_left;
145 return boost::indeterminate;
146 case length_4bytes_left:
147 frame.
length |= ((uint64_t)(input & 0xFF) << 24);
148 state_ = length_3bytes_left;
149 return boost::indeterminate;
150 case length_3bytes_left:
151 frame.
length |= ((uint64_t)(input & 0xFF) << 16);
152 state_ = length_2bytes_left;
153 return boost::indeterminate;
154 case length_2bytes_left:
155 frame.
length |= ((uint64_t)(input & 0xFF) << 8);
156 state_ = length_1bytes_left;
157 return boost::indeterminate;
158 case length_1bytes_left:
159 frame.
length |= ((uint64_t)(input & 0xFF) << 0);
166 return boost::indeterminate;
169 frame.
mask[0] = input;
171 return boost::indeterminate;
173 frame.
mask[1] = input;
175 return boost::indeterminate;
177 frame.
mask[2] = input;
179 return boost::indeterminate;
181 frame.
mask[3] = input;
186 return boost::indeterminate;
191 return boost::indeterminate;
195 for (uint64_t i = 0; i < frame.
length; ++i)
211 if (frame.
header.opcode == WebsocketFrame::Header::opcode_continuation)
220 switch (frame.
header.opcode)
222 case WebsocketFrame::Header::opcode_text:
225 case WebsocketFrame::Header::opcode_binary:
228 case WebsocketFrame::Header::opcode_close:
231 case WebsocketFrame::Header::opcode_ping:
234 case WebsocketFrame::Header::opcode_pong:
246 return boost::indeterminate;
boost::tribool consume(WebsocketFrame &frame, char input)
bool fromMessage(const WebsocketMessage &message)
boost::tribool consume(WebsocketMessage &message, WebsocketFrame &frame)
bool serialize(std::vector< unsigned char > &buffer)