diff --git a/src/guacd/client.c b/src/guacd/client.c index 82debe82..2880fab9 100644 --- a/src/guacd/client.c +++ b/src/guacd/client.c @@ -74,17 +74,17 @@ void* __guacd_client_output_thread(void* data) { /* Guacamole client output loop */ while (client->state == GUAC_CLIENT_RUNNING) { - /* Occasionally ping client with repeat of last sync */ + /* Occasionally send client NOP keep-alive */ guac_timestamp timestamp = guac_timestamp_current(); if (timestamp - last_ping_timestamp > GUACD_SYNC_FREQUENCY) { /* Record time of last synnc */ last_ping_timestamp = timestamp; - /* Send sync */ - if (guac_protocol_send_sync(socket, client->last_sent_timestamp)) { + /* Send NOP */ + if (guac_protocol_send_nop(socket)) { guacd_client_log_guac_error(client, - "Error sending \"sync\" instruction"); + "Error sending \"nop\" keep-alive"); guac_client_stop(client); return NULL; } diff --git a/src/libguac/guacamole/protocol.h b/src/libguac/guacamole/protocol.h index d89d05d0..e23e0a28 100644 --- a/src/libguac/guacamole/protocol.h +++ b/src/libguac/guacamole/protocol.h @@ -232,6 +232,18 @@ int guac_protocol_send_error(guac_socket* socket, const char* error); int guac_protocol_send_nest(guac_socket* socket, int index, const char* data); +/** + * Sends a nop instruction (null-operation) 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. + * @return Zero on success, non-zero on error. + */ +int guac_protocol_send_nop(guac_socket* socket); + /** * Sends a set instruction over the given guac_socket connection. * diff --git a/src/libguac/protocol.c b/src/libguac/protocol.c index 5303538e..266c9cd4 100644 --- a/src/libguac/protocol.c +++ b/src/libguac/protocol.c @@ -951,6 +951,18 @@ int guac_protocol_send_nest(guac_socket* socket, int index, } +int guac_protocol_send_nop(guac_socket* socket) { + + int ret_val; + + guac_socket_instruction_begin(socket); + ret_val = guac_socket_write_string(socket, "3.nop;"); + guac_socket_instruction_end(socket); + + return ret_val; + +} + int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode, const guac_layer* layer, int x, int y, cairo_surface_t* surface) {