diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index dd02b564..1020406e 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -52,6 +52,7 @@ AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio # Checks for library functions. AC_FUNC_MALLOC +AC_CHECK_FUNCS([nanosleep]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 67229685..3ad50459 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -217,6 +217,23 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { } +void vnc_guac_client_sleep(int millis) { + +#ifdef HAVE_NANOSLEEP + struct timespec sleep_period; + + sleep_period.tv_sec = 0; + sleep_period.tv_nsec = millis * 1000000L; + + nanosleep(&sleep_period, NULL); +#elif defined(__MINGW32__) + Sleep(millis) +#else +#warning No sleep/nanosleep function available. VNC client may not perform as expected. Consider editing the vnc_client.c to add support for your platform. +#endif + +} + int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; @@ -236,6 +253,11 @@ int vnc_guac_client_handle_messages(guac_client* client) { return 1; } + /* Wait before returning ... don't want to handle + * too many server messages. */ + + vnc_guac_client_sleep(50); + } return 0;