/** * Socket unlock handler which releases the socket locks of all connected users. * Socket-level locks are released after a Guacamole instruction has finished * being written. * * @param socket * The broadcast socket to unlock. */ static void __guac_socket_broadcast_unlock_handler(guac_socket* socket) { guac_client* client = (guac_client*) socket->data; /* Unlock sockets of all users */ guac_client_foreach_user(client, __unlock_callback, NULL); }
int guac_client_get_processing_lag(guac_client* client) { int processing_lag = 0; /* Approximate the processing lag of all users */ guac_client_foreach_user(client, __calculate_lag, &processing_lag); return processing_lag; }
/** * Socket flush handler which operates on each of the sockets of all connected * users. This flush handler will always succeed, but any failing user-specific * flush will invoke guac_user_stop() on the failing user. * * @param socket * The broadcast socket to flush. * * @return * Zero if the flush operation succeeds, non-zero if the operation fails. * This handler will always succeed, and thus will always return zero. */ static ssize_t __guac_socket_broadcast_flush_handler(guac_socket* socket) { guac_client* client = (guac_client*) socket->data; /* Flush all users */ guac_client_foreach_user(client, __flush_callback, NULL); return 0; }
int guac_client_supports_webp(guac_client* client) { #ifdef ENABLE_WEBP int webp_supported = 1; /* WebP is supported for entire client only if each user supports it */ guac_client_foreach_user(client, __webp_support_callback, &webp_supported); return webp_supported; #else /* Support for WebP is completely absent */ return 0; #endif }
/** * Socket write handler which operates on each of the sockets of all connected * users. This write handler will always succeed, but any failing user-specific * writes will invoke guac_user_stop() on the failing user. * * @param socket * The socket to which the given data must be written. * * @param buf * The buffer containing the data to write. * * @param count * The number of bytes to attempt to write from the given buffer. * * @return * The number of bytes written, or -1 if an error occurs. This handler will * always succeed, and thus will always return the exact number of bytes * specified by count. */ static ssize_t __guac_socket_broadcast_write_handler(guac_socket* socket, const void* buf, size_t count) { guac_client* client = (guac_client*) socket->data; /* Build chunk */ __write_chunk chunk; chunk.buffer = buf; chunk.length = count; /* Broadcast chunk to all users */ guac_client_foreach_user(client, __write_chunk_callback, &chunk); return count; }
void guac_common_clipboard_send(guac_common_clipboard* clipboard, guac_client* client) { guac_client_log(client, GUAC_LOG_DEBUG, "Broadcasting clipboard to all connected users."); guac_client_foreach_user(client, __send_user_clipboard, clipboard); guac_client_log(client, GUAC_LOG_DEBUG, "Broadcast of clipboard complete."); }