Add support for NOP.

This commit is contained in:
Michael Jumper 2013-10-09 11:54:33 -07:00
parent 8a8ad23312
commit 4ebafa0482
3 changed files with 28 additions and 4 deletions

View File

@ -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;
}

View File

@ -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.
*

View File

@ -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) {