From 86a59c43b3438e5cf30119566ef245ab2413fae0 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 26 Jun 2014 15:23:00 -0700 Subject: [PATCH] GUAC-744: Send ready instruction after guac_client_init. --- src/guacd/daemon.c | 2 ++ src/libguac/guacamole/protocol.h | 12 ++++++++++++ src/libguac/protocol.c | 15 +++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c index 0bce88d2..cbcceb1c 100644 --- a/src/guacd/daemon.c +++ b/src/guacd/daemon.c @@ -236,7 +236,9 @@ void guacd_handle_connection(guac_socket* socket) { return; } + /* Send connection ID */ guacd_log_info("Connection ID is \"%s\"", client->connection_id); + guac_protocol_send_ready(socket, client->connection_id); /* Start client threads */ guacd_log_info("Starting client"); diff --git a/src/libguac/guacamole/protocol.h b/src/libguac/guacamole/protocol.h index 685523b4..905d8191 100644 --- a/src/libguac/guacamole/protocol.h +++ b/src/libguac/guacamole/protocol.h @@ -165,6 +165,18 @@ int guac_protocol_send_nest(guac_socket* socket, int index, */ int guac_protocol_send_nop(guac_socket* socket); +/** + * Sends a ready instruction over the given guac_socket connection. + * + * If an error occurs sending the instruction, a non-zero value is + * returned, and guac_error is set appropriately. + * + * @param socket The guac_socket connection to use. + * @param id The connection ID of the connection that is ready. + * @return Zero on success, non-zero on error. + */ +int guac_protocol_send_ready(guac_socket* socket, const char* id); + /** * Sends a set instruction over the given guac_socket connection. * diff --git a/src/libguac/protocol.c b/src/libguac/protocol.c index 27ecf8d1..62751fce 100644 --- a/src/libguac/protocol.c +++ b/src/libguac/protocol.c @@ -1060,6 +1060,21 @@ int guac_protocol_send_push(guac_socket* socket, const guac_layer* layer) { } +int guac_protocol_send_ready(guac_socket* socket, const char* id) { + + int ret_val; + + guac_socket_instruction_begin(socket); + ret_val = + guac_socket_write_string(socket, "5.ready,") + || __guac_socket_write_length_string(socket, id) + || guac_socket_write_string(socket, ";"); + + guac_socket_instruction_end(socket); + return ret_val; + +} + int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer, int x, int y, int width, int height) {