diff --git a/src/protocols/vnc/guac_handlers.c b/src/protocols/vnc/guac_handlers.c index f3b2fd49..2377e7b1 100644 --- a/src/protocols/vnc/guac_handlers.c +++ b/src/protocols/vnc/guac_handlers.c @@ -52,19 +52,25 @@ int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + /* Initially wait for messages */ wait_result = WaitForMessage(rfb_client, 1000000); - if (wait_result < 0) { - guac_client_log_error(client, "Error waiting for VNC server message\n"); - return 1; - } - - if (wait_result > 0) { + while (wait_result > 0) { + /* Handle any message received */ if (!HandleRFBServerMessage(rfb_client)) { guac_client_log_error(client, "Error handling VNC server message\n"); return 1; } + /* Check for additional messages */ + wait_result = WaitForMessage(rfb_client, 0); + + } + + /* If an error occurs, log it and fail */ + if (wait_result < 0) { + guac_client_log_error(client, "Error waiting for VNC server message\n"); + return 1; } return 0;