Ed Tanous | eb1b862 | 2017-04-25 14:11:46 -0700 | [diff] [blame] | 1 | #include <string> |
Ed Tanous | 7d3dba4 | 2017-04-05 13:04:39 -0700 | [diff] [blame] | 2 | #include <crow/app.h> |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 3 | #include <boost/endian/arithmetic.hpp> |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 4 | |
Ed Tanous | 93f987d | 2017-04-17 17:52:36 -0700 | [diff] [blame] | 5 | #include <ast_jpeg_decoder.hpp> |
| 6 | #include <ast_video_puller.hpp> |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 7 | |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 8 | namespace crow { |
| 9 | namespace kvm { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 10 | |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 11 | static const std::string rfb_3_3_version_string = "RFB 003.003\n"; |
| 12 | static const std::string rfb_3_7_version_string = "RFB 003.007\n"; |
| 13 | static const std::string rfb_3_8_version_string = "RFB 003.008\n"; |
| 14 | |
| 15 | enum class RfbAuthScheme : uint8_t { |
| 16 | connection_failed = 0, |
| 17 | no_authentication = 1, |
| 18 | vnc_authentication = 2 |
| 19 | }; |
| 20 | |
| 21 | struct pixel_format_struct { |
| 22 | boost::endian::big_uint8_t bits_per_pixel; |
| 23 | boost::endian::big_uint8_t depth; |
| 24 | boost::endian::big_uint8_t is_big_endian; |
| 25 | boost::endian::big_uint8_t is_true_color; |
| 26 | boost::endian::big_uint16_t red_max; |
| 27 | boost::endian::big_uint16_t green_max; |
| 28 | boost::endian::big_uint16_t blue_max; |
| 29 | boost::endian::big_uint8_t red_shift; |
| 30 | boost::endian::big_uint8_t green_shift; |
| 31 | boost::endian::big_uint8_t blue_shift; |
| 32 | boost::endian::big_uint8_t pad1; |
| 33 | boost::endian::big_uint8_t pad2; |
| 34 | boost::endian::big_uint8_t pad3; |
| 35 | }; |
| 36 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 37 | struct server_initialization_msg { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 38 | boost::endian::big_uint16_t framebuffer_width; |
| 39 | boost::endian::big_uint16_t framebuffer_height; |
| 40 | pixel_format_struct pixel_format; |
| 41 | boost::endian::big_uint32_t name_length; |
| 42 | }; |
| 43 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 44 | enum class client_to_server_msg_type : uint8_t { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 45 | set_pixel_format = 0, |
| 46 | fix_color_map_entries = 1, |
| 47 | set_encodings = 2, |
| 48 | framebuffer_update_request = 3, |
| 49 | key_event = 4, |
| 50 | pointer_event = 5, |
| 51 | client_cut_text = 6 |
| 52 | }; |
| 53 | |
Ed Tanous | eb1b862 | 2017-04-25 14:11:46 -0700 | [diff] [blame] | 54 | enum class server_to_client_message_type : uint8_t { |
| 55 | framebuffer_update = 0, |
| 56 | set_color_map_entries = 1, |
| 57 | bell_message = 2, |
| 58 | server_cut_text = 3 |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 61 | struct set_pixel_format_msg { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 62 | boost::endian::big_uint8_t pad1; |
| 63 | boost::endian::big_uint8_t pad2; |
| 64 | boost::endian::big_uint8_t pad3; |
| 65 | pixel_format_struct pixel_format; |
| 66 | }; |
| 67 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 68 | struct frame_buffer_update_req { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 69 | boost::endian::big_uint8_t incremental; |
| 70 | boost::endian::big_uint16_t x_position; |
| 71 | boost::endian::big_uint16_t y_position; |
| 72 | boost::endian::big_uint16_t width; |
| 73 | boost::endian::big_uint16_t height; |
| 74 | }; |
| 75 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 76 | struct key_event_msg { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 77 | boost::endian::big_uint8_t down_flag; |
| 78 | boost::endian::big_uint8_t pad1; |
| 79 | boost::endian::big_uint8_t pad2; |
| 80 | boost::endian::big_uint32_t key; |
| 81 | }; |
| 82 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 83 | struct pointer_event_msg { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 84 | boost::endian::big_uint8_t button_mask; |
| 85 | boost::endian::big_uint16_t x_position; |
| 86 | boost::endian::big_uint16_t y_position; |
| 87 | }; |
| 88 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 89 | struct client_cut_text_msg { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 90 | std::vector<uint8_t> data; |
| 91 | }; |
| 92 | |
| 93 | enum class encoding_type : uint32_t { |
| 94 | raw = 0x00, |
| 95 | copy_rectangle = 0x01, |
| 96 | rising_rectangle = 0x02, |
| 97 | corre = 0x04, |
| 98 | hextile = 0x05, |
| 99 | zlib = 0x06, |
| 100 | tight = 0x07, |
| 101 | zlibhex = 0x08, |
| 102 | ultra = 0x09, |
| 103 | zrle = 0x10, |
| 104 | zywrle = 0x011, |
| 105 | cache_enable = 0xFFFF0001, |
| 106 | xor_enable = 0xFFFF0006, |
| 107 | server_state_ultranvc = 0xFFFF8000, |
| 108 | enable_keep_alive = 0xFFFF8001, |
| 109 | enableftp_protocol_version = 0xFFFF8002, |
| 110 | tight_compress_level_0 = 0xFFFFFF00, |
| 111 | tight_compress_level_9 = 0xFFFFFF09, |
| 112 | x_cursor = 0xFFFFFF10, |
| 113 | rich_cursor = 0xFFFFFF11, |
| 114 | pointer_pos = 0xFFFFFF18, |
| 115 | last_rect = 0xFFFFFF20, |
| 116 | new_framebuffer_size = 0xFFFFFF21, |
| 117 | tight_quality_level_0 = 0xFFFFFFE0, |
| 118 | tight_quality_level_9 = 0xFFFFFFE9 |
| 119 | }; |
| 120 | |
| 121 | struct framebuffer_rectangle { |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 122 | boost::endian::big_uint16_t x{}; |
| 123 | boost::endian::big_uint16_t y{}; |
| 124 | boost::endian::big_uint16_t width{}; |
| 125 | boost::endian::big_uint16_t height{}; |
| 126 | boost::endian::big_uint32_t encoding{}; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 127 | std::vector<uint8_t> data; |
| 128 | }; |
| 129 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 130 | struct framebuffer_update_msg { |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 131 | boost::endian::big_uint8_t message_type{}; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 132 | std::vector<framebuffer_rectangle> rectangles; |
| 133 | }; |
| 134 | |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 135 | inline std::string serialize(const framebuffer_update_msg& msg) { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 136 | // calculate the size of the needed vector for serialization |
| 137 | size_t vector_size = 4; |
| 138 | for (const auto& rect : msg.rectangles) { |
| 139 | vector_size += 12 + rect.data.size(); |
| 140 | } |
| 141 | |
| 142 | std::string serialized(vector_size, 0); |
| 143 | |
| 144 | size_t i = 0; |
Ed Tanous | eb1b862 | 2017-04-25 14:11:46 -0700 | [diff] [blame] | 145 | serialized[i++] = static_cast<char>( |
| 146 | server_to_client_message_type::framebuffer_update); // Type |
| 147 | serialized[i++] = 0; // Pad byte |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 148 | boost::endian::big_uint16_t number_of_rectangles = msg.rectangles.size(); |
| 149 | std::memcpy(&serialized[i], &number_of_rectangles, |
| 150 | sizeof(number_of_rectangles)); |
| 151 | i += sizeof(number_of_rectangles); |
| 152 | |
| 153 | for (const auto& rect : msg.rectangles) { |
| 154 | // copy the first part of the struct |
| 155 | size_t buffer_size = |
| 156 | sizeof(framebuffer_rectangle) - sizeof(std::vector<uint8_t>); |
| 157 | std::memcpy(&serialized[i], &rect, buffer_size); |
| 158 | i += buffer_size; |
| 159 | |
| 160 | std::memcpy(&serialized[i], rect.data.data(), rect.data.size()); |
| 161 | i += rect.data.size(); |
| 162 | } |
| 163 | |
| 164 | return serialized; |
| 165 | } |
| 166 | |
| 167 | enum class VncState { |
| 168 | UNSTARTED, |
| 169 | AWAITING_CLIENT_VERSION, |
| 170 | AWAITING_CLIENT_AUTH_METHOD, |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 171 | AWAITING_CLIENT_INIT_msg, |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 172 | MAIN_LOOP |
| 173 | }; |
| 174 | |
| 175 | class connection_metadata { |
| 176 | public: |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 177 | connection_metadata() {}; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 178 | |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 179 | VncState vnc_state{VncState::UNSTARTED}; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 182 | using meta_list = std::vector<connection_metadata>; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 183 | meta_list connection_states(10); |
| 184 | |
| 185 | connection_metadata meta; |
| 186 | |
Ed Tanous | 7d3dba4 | 2017-04-05 13:04:39 -0700 | [diff] [blame] | 187 | template <typename... Middlewares> |
| 188 | void request_routes(Crow<Middlewares...>& app) { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 189 | CROW_ROUTE(app, "/kvmws") |
| 190 | .websocket() |
| 191 | .onopen([&](crow::websocket::connection& conn) { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 192 | if (meta.vnc_state == VncState::UNSTARTED) { |
| 193 | meta.vnc_state = VncState::AWAITING_CLIENT_VERSION; |
| 194 | conn.send_binary(rfb_3_8_version_string); |
Ed Tanous | 01250f2 | 2017-04-18 17:49:51 -0700 | [diff] [blame] | 195 | } else { // SHould never happen |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 196 | conn.close(); |
| 197 | } |
| 198 | |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 199 | }) |
| 200 | .onclose( |
| 201 | [&](crow::websocket::connection& conn, const std::string& reason) { |
| 202 | meta.vnc_state = VncState::UNSTARTED; |
| 203 | }) |
| 204 | .onmessage([&](crow::websocket::connection& conn, const std::string& data, |
| 205 | bool is_binary) { |
| 206 | switch (meta.vnc_state) { |
| 207 | case VncState::AWAITING_CLIENT_VERSION: { |
Ed Tanous | 4d92cbf | 2017-06-22 15:41:02 -0700 | [diff] [blame] | 208 | std::cout << "Client sent: " << data; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 209 | if (data == rfb_3_8_version_string || |
| 210 | data == rfb_3_7_version_string) { |
| 211 | std::string auth_types{1, |
| 212 | (uint8_t)RfbAuthScheme::no_authentication}; |
| 213 | conn.send_binary(auth_types); |
| 214 | meta.vnc_state = VncState::AWAITING_CLIENT_AUTH_METHOD; |
| 215 | } else if (data == rfb_3_3_version_string) { |
| 216 | // TODO(ed) Support older protocols |
| 217 | meta.vnc_state = VncState::UNSTARTED; |
| 218 | conn.close(); |
| 219 | } else { |
| 220 | // TODO(ed) Support older protocols |
| 221 | meta.vnc_state = VncState::UNSTARTED; |
| 222 | conn.close(); |
| 223 | } |
| 224 | } break; |
| 225 | case VncState::AWAITING_CLIENT_AUTH_METHOD: { |
| 226 | std::string security_result{{0, 0, 0, 0}}; |
| 227 | if (data[0] == (uint8_t)RfbAuthScheme::no_authentication) { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 228 | meta.vnc_state = VncState::AWAITING_CLIENT_INIT_msg; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 229 | } else { |
| 230 | // Mark auth as failed |
| 231 | security_result[3] = 1; |
| 232 | meta.vnc_state = VncState::UNSTARTED; |
| 233 | } |
| 234 | conn.send_binary(security_result); |
| 235 | } break; |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 236 | case VncState::AWAITING_CLIENT_INIT_msg: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 237 | // Now send the server initialization |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 238 | server_initialization_msg server_init_msg{}; |
Ed Tanous | 93f987d | 2017-04-17 17:52:36 -0700 | [diff] [blame] | 239 | server_init_msg.framebuffer_width = 800; |
| 240 | server_init_msg.framebuffer_height = 600; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 241 | server_init_msg.pixel_format.bits_per_pixel = 32; |
| 242 | server_init_msg.pixel_format.is_big_endian = 0; |
| 243 | server_init_msg.pixel_format.is_true_color = 1; |
| 244 | server_init_msg.pixel_format.red_max = 255; |
| 245 | server_init_msg.pixel_format.green_max = 255; |
| 246 | server_init_msg.pixel_format.blue_max = 255; |
| 247 | server_init_msg.pixel_format.red_shift = 16; |
| 248 | server_init_msg.pixel_format.green_shift = 8; |
| 249 | server_init_msg.pixel_format.blue_shift = 0; |
| 250 | server_init_msg.name_length = 0; |
Ed Tanous | 4d92cbf | 2017-06-22 15:41:02 -0700 | [diff] [blame] | 251 | std::cout << "size: " << sizeof(server_init_msg); |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 252 | // TODO(ed) this is ugly. Crow should really have a span type |
| 253 | // interface |
| 254 | // to avoid the copy, but alas, today it does not. |
| 255 | std::string s(reinterpret_cast<char*>(&server_init_msg), |
| 256 | sizeof(server_init_msg)); |
Ed Tanous | 4d92cbf | 2017-06-22 15:41:02 -0700 | [diff] [blame] | 257 | std::cout << "s.size() " << s.size(); |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 258 | conn.send_binary(s); |
| 259 | meta.vnc_state = VncState::MAIN_LOOP; |
| 260 | } break; |
| 261 | case VncState::MAIN_LOOP: { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 262 | if (data.size() >= sizeof(client_to_server_msg_type)) { |
| 263 | auto type = static_cast<client_to_server_msg_type>(data[0]); |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 264 | std::cout << "Received client message type " |
| 265 | << static_cast<std::size_t>(type) << "\n"; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 266 | switch (type) { |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 267 | case client_to_server_msg_type::set_pixel_format: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 268 | } break; |
| 269 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 270 | case client_to_server_msg_type::fix_color_map_entries: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 271 | } break; |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 272 | case client_to_server_msg_type::set_encodings: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 273 | } break; |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 274 | case client_to_server_msg_type::framebuffer_update_request: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 275 | // Make sure the buffer is long enough to handle what we're |
| 276 | // about to do |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 277 | if (data.size() >= sizeof(frame_buffer_update_req) + |
| 278 | sizeof(client_to_server_msg_type)) { |
| 279 | auto msg = reinterpret_cast<const frame_buffer_update_req*>( |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 280 | data.data() + // NOLINT |
| 281 | sizeof(client_to_server_msg_type)); |
| 282 | // TODO(ed) find a better way to do this deserialization |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 283 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 284 | // Todo(ed) lifecycle of the video puller and decoder |
| 285 | // should be |
| 286 | // with the websocket, not recreated every time |
Ed Tanous | e2fc45a | 2017-04-26 09:19:10 -0700 | [diff] [blame] | 287 | AstVideo::SimpleVideoPuller p; |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 288 | p.initialize(); |
| 289 | auto out = p.read_video(); |
| 290 | AstVideo::AstJpegDecoder d; |
| 291 | d.decode(out.buffer, out.width, out.height, out.mode, |
| 292 | out.y_selector, out.uv_selector); |
Ed Tanous | 93f987d | 2017-04-17 17:52:36 -0700 | [diff] [blame] | 293 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 294 | framebuffer_update_msg buffer_update_msg; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 295 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 296 | // If the viewer is requesting a full update, force write |
| 297 | // of all pixels |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 298 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 299 | framebuffer_rectangle this_rect; |
| 300 | this_rect.x = msg->x_position; |
| 301 | this_rect.y = msg->y_position; |
| 302 | this_rect.width = out.width; |
| 303 | this_rect.height = out.height; |
| 304 | this_rect.encoding = |
| 305 | static_cast<uint8_t>(encoding_type::raw); |
Ed Tanous | 4d92cbf | 2017-06-22 15:41:02 -0700 | [diff] [blame] | 306 | std::cout << "Encoding is " << this_rect.encoding; |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 307 | this_rect.data.reserve( |
| 308 | static_cast<std::size_t>(this_rect.width) * |
| 309 | static_cast<std::size_t>(this_rect.height) * 4); |
Ed Tanous | 4d92cbf | 2017-06-22 15:41:02 -0700 | [diff] [blame] | 310 | std::cout << "Width " << out.width << " Height " |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 311 | << out.height; |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 312 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 313 | for (int i = 0; i < out.width * out.height; i++) { |
| 314 | auto& pixel = d.OutBuffer[i]; |
| 315 | this_rect.data.push_back(pixel.B); |
| 316 | this_rect.data.push_back(pixel.G); |
| 317 | this_rect.data.push_back(pixel.R); |
| 318 | this_rect.data.push_back(0); |
| 319 | } |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 320 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 321 | buffer_update_msg.rectangles.push_back( |
| 322 | std::move(this_rect)); |
| 323 | auto serialized = serialize(buffer_update_msg); |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 324 | |
Ed Tanous | 9140a67 | 2017-04-24 17:01:32 -0700 | [diff] [blame] | 325 | conn.send_binary(serialized); |
Ed Tanous | 01250f2 | 2017-04-18 17:49:51 -0700 | [diff] [blame] | 326 | |
Ed Tanous | 93f987d | 2017-04-17 17:52:36 -0700 | [diff] [blame] | 327 | } // TODO(Ed) handle error |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 328 | |
| 329 | } |
| 330 | |
| 331 | break; |
| 332 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 333 | case client_to_server_msg_type::key_event: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 334 | } break; |
| 335 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 336 | case client_to_server_msg_type::pointer_event: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 337 | } break; |
| 338 | |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 339 | case client_to_server_msg_type::client_cut_text: { |
Ed Tanous | c81ca42 | 2017-03-21 16:18:49 -0700 | [diff] [blame] | 340 | } break; |
| 341 | |
| 342 | default: |
| 343 | break; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | } break; |
| 348 | case VncState::UNSTARTED: |
| 349 | // Error? TODO |
| 350 | break; |
| 351 | } |
| 352 | |
| 353 | }); |
| 354 | } |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 355 | } // namespace kvm |
| 356 | } // namespace crow |