libguac 1.5.5
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
client.h File Reference

Functions and structure contents for the Guacamole proxy client. More...

Go to the source code of this file.

Data Structures

struct  guac_client
 Guacamole proxy client. More...
 

Functions

guac_clientguac_client_alloc ()
 Returns a new, barebones guac_client.
 
void guac_client_free (guac_client *client)
 Free all resources associated with the given client.
 
void guac_client_log (guac_client *client, guac_client_log_level level, const char *format,...)
 Writes a message in the log used by the given client.
 
void vguac_client_log (guac_client *client, guac_client_log_level level, const char *format, va_list ap)
 Writes a message in the log used by the given client.
 
void guac_client_stop (guac_client *client)
 Signals the given client to stop gracefully.
 
void guac_client_abort (guac_client *client, guac_protocol_status status, const char *format,...)
 Signals the given client to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.
 
void vguac_client_abort (guac_client *client, guac_protocol_status status, const char *format, va_list ap)
 Signals the given client to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.
 
guac_layerguac_client_alloc_buffer (guac_client *client)
 Allocates a new buffer (invisible layer).
 
guac_layerguac_client_alloc_layer (guac_client *client)
 Allocates a new layer.
 
void guac_client_free_buffer (guac_client *client, guac_layer *layer)
 Returns the given buffer to the pool of available buffers, such that it can be reused by any subsequent call to guac_client_allow_buffer().
 
void guac_client_free_layer (guac_client *client, guac_layer *layer)
 Returns the given layer to the pool of available layers, such that it can be reused by any subsequent call to guac_client_allow_layer().
 
guac_streamguac_client_alloc_stream (guac_client *client)
 Allocates a new stream.
 
void guac_client_free_stream (guac_client *client, guac_stream *stream)
 Returns the given stream to the pool of available streams, such that it can be reused by any subsequent call to guac_client_alloc_stream().
 
int guac_client_add_user (guac_client *client, guac_user *user, int argc, char **argv)
 Adds the given user to the internal list of connected users.
 
void guac_client_remove_user (guac_client *client, guac_user *user)
 Removes the given user, removing the user from the internally-tracked list of connected users, and calling any appropriate leave handler.
 
void guac_client_foreach_user (guac_client *client, guac_user_callback *callback, void *data)
 Calls the given function on all currently-connected users of the given client.
 
void guac_client_foreach_pending_user (guac_client *client, guac_user_callback *callback, void *data)
 Calls the given function on all pending users of the given client.
 
void * guac_client_for_owner (guac_client *client, guac_user_callback *callback, void *data)
 Calls the given function with the currently-connected user that is marked as the owner.
 
void * guac_client_for_user (guac_client *client, guac_user *user, guac_user_callback *callback, void *data)
 Calls the given function with the given user ONLY if they are currently connected.
 
int guac_client_end_frame (guac_client *client)
 Marks the end of the current frame by sending a "sync" instruction to all connected users.
 
int guac_client_load_plugin (guac_client *client, const char *protocol)
 Initializes the given guac_client using the initialization routine provided by the plugin corresponding to the named protocol.
 
int guac_client_get_processing_lag (guac_client *client)
 Calculates and returns the approximate processing lag experienced by the pool of users.
 
int guac_client_owner_send_required (guac_client *client, const char **required)
 Sends a request to the owner of the given guac_client for parameters required to continue the connection started by the client.
 
void guac_client_stream_argv (guac_client *client, guac_socket *socket, const char *mimetype, const char *name, const char *value)
 Streams the given connection parameter value over an argument value stream ("argv" instruction), exposing the current value of the named connection parameter to all users of the given client.
 
void guac_client_stream_png (guac_client *client, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface)
 Streams the image data of the given surface over an image stream ("img" instruction) as PNG-encoded data.
 
void guac_client_stream_jpeg (guac_client *client, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface, int quality)
 Streams the image data of the given surface over an image stream ("img" instruction) as JPEG-encoded data at the given quality.
 
void guac_client_stream_webp (guac_client *client, guac_socket *socket, guac_composite_mode mode, const guac_layer *layer, int x, int y, cairo_surface_t *surface, int quality, int lossless)
 Streams the image data of the given surface over an image stream ("img" instruction) as WebP-encoded data at the given quality.
 
int guac_client_owner_supports_msg (guac_client *client)
 Returns whether the owner of the given client supports the "msg" instruction, returning non-zero if the client owner does support the instruction, or zero if the owner does not.
 
int guac_client_owner_supports_required (guac_client *client)
 Returns whether the owner of the given client supports the "required" instruction, returning non-zero if the client owner does support the instruction, or zero if the owner does not.
 
int guac_client_owner_notify_join (guac_client *client, guac_user *joiner)
 Notifies the owner of the given client that a user has joined the connection, and returns zero if the message was sent successfully, or non-zero if the notification failed.
 
int guac_client_owner_notify_leave (guac_client *client, guac_user *quitter)
 Notifies the owner of the given client that a user has left the connection, and returns zero if the message was sent successfully, or non-zero if the notification failed.
 
int guac_client_supports_webp (guac_client *client)
 Returns whether all users of the given client support WebP.
 

Variables

const guac_layerGUAC_DEFAULT_LAYER
 The default Guacamole client layer, layer 0.
 

Detailed Description

Functions and structure contents for the Guacamole proxy client.

Function Documentation

◆ guac_client_abort()

void guac_client_abort ( guac_client * client,
guac_protocol_status status,
const char * format,
... )

Signals the given client to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.

Note that this is a completely cooperative signal, and can be ignored by the client or the hosting daemon. The message given will be logged to the system logs.

Parameters
clientThe proxy client to signal to stop.
statusThe status to send over the Guacamole protocol.
formatA printf-style format string to log.
...Arguments to use when filling the format string for printing.

◆ guac_client_add_user()

int guac_client_add_user ( guac_client * client,
guac_user * user,
int argc,
char ** argv )

Adds the given user to the internal list of connected users.

Future writes to the broadcast socket stored within guac_client will also write to this user. The join handler of this guac_client will be called.

Parameters
clientThe proxy client to add the user to.
userThe user to add.
argcThe number of arguments to pass to the new user.
argvAn array of strings containing the argument values being passed.
Returns
Zero if the user was added successfully, non-zero if the user could not join the connection.

◆ guac_client_alloc()

guac_client * guac_client_alloc ( )

Returns a new, barebones guac_client.

This new guac_client has no handlers set, but is otherwise usable.

Returns
A pointer to the new client.

◆ guac_client_alloc_buffer()

guac_layer * guac_client_alloc_buffer ( guac_client * client)

Allocates a new buffer (invisible layer).

An arbitrary index is automatically assigned if no existing buffer is available for use.

Parameters
clientThe proxy client to allocate the buffer for.
Returns
The next available buffer, or a newly allocated buffer.

◆ guac_client_alloc_layer()

guac_layer * guac_client_alloc_layer ( guac_client * client)

Allocates a new layer.

An arbitrary index is automatically assigned if no existing layer is available for use.

Parameters
clientThe proxy client to allocate the layer buffer for.
Returns
The next available layer, or a newly allocated layer.

◆ guac_client_alloc_stream()

guac_stream * guac_client_alloc_stream ( guac_client * client)

Allocates a new stream.

An arbitrary index is automatically assigned if no previously-allocated stream is available for use.

Parameters
clientThe client to allocate the stream for.
Returns
The next available stream, or a newly allocated stream, or NULL if the maximum number of active streams has been reached.

◆ guac_client_end_frame()

int guac_client_end_frame ( guac_client * client)

Marks the end of the current frame by sending a "sync" instruction to all connected users.

This instruction will contain the current timestamp. The last_sent_timestamp member of guac_client will be updated accordingly.

If an error occurs sending the instruction, a non-zero value is returned, and guac_error is set appropriately.

Parameters
clientThe guac_client which has finished a frame.
Returns
Zero on success, non-zero on error.

◆ guac_client_for_owner()

void * guac_client_for_owner ( guac_client * client,
guac_user_callback * callback,
void * data )

Calls the given function with the currently-connected user that is marked as the owner.

The owner of a connection is the user that established the initial connection that created the connection (the first user to connect and join). The function will be given a reference to the guac_user and the specified arbitrary data. If the owner has since left the connection, the function will instead be invoked with NULL as the guac_user. The value returned by the callback will be returned by this function.

This function is reentrant, but the user list MUST NOT be manipulated within the same thread as a callback to this function.

Parameters
clientThe client to retrieve the owner from.
callbackThe callback to invoke on the user marked as the owner of the connection. NULL will be passed to this callback instead if there is no owner.
dataArbitrary data to pass to the given callback.
Returns
The value returned by the callback.

◆ guac_client_for_user()

void * guac_client_for_user ( guac_client * client,
guac_user * user,
guac_user_callback * callback,
void * data )

Calls the given function with the given user ONLY if they are currently connected.

The function will be given a reference to the guac_user and the specified arbitrary data. If the provided user doesn't exist or has since left the connection, the function will instead be invoked with NULL as the guac_user. The value returned by the callback will be returned by this function.

This function is reentrant, but the user list MUST NOT be manipulated within the same thread as a callback to this function.

Parameters
clientThe client that the given user is expected to be associated with.
userThe user to provide to the given callback if valid. The pointer need not even point to properly allocated memory; the user will only be passed to the callback function if they are valid, and the provided user pointer will not be dereferenced during this process.
callbackThe callback to invoke on the given user if they are valid. NULL will be passed to this callback instead if the user is not valid.
dataArbitrary data to pass to the given callback.
Returns
The value returned by the callback.

◆ guac_client_foreach_pending_user()

void guac_client_foreach_pending_user ( guac_client * client,
guac_user_callback * callback,
void * data )

Calls the given function on all pending users of the given client.

The function will be given a reference to a guac_user and the specified arbitrary data. The value returned by the callback will be ignored.

This function is reentrant, but the pending user list MUST NOT be manipulated within the same thread as a callback to this function.

Parameters
clientThe client whose users should be iterated.
callbackThe function to call for each pending user.
dataArbitrary data to pass to the callback each time it is invoked.

◆ guac_client_foreach_user()

void guac_client_foreach_user ( guac_client * client,
guac_user_callback * callback,
void * data )

Calls the given function on all currently-connected users of the given client.

The function will be given a reference to a guac_user and the specified arbitrary data. The value returned by the callback will be ignored.

This function is reentrant, but the user list MUST NOT be manipulated within the same thread as a callback to this function. Though the callback MAY invoke guac_client_foreach_user(), doing so should not be necessary, and may indicate poor design choices.

Parameters
clientThe client whose users should be iterated.
callbackThe function to call for each user.
dataArbitrary data to pass to the callback each time it is invoked.

◆ guac_client_free()

void guac_client_free ( guac_client * client)

Free all resources associated with the given client.

Parameters
clientThe proxy client to free all resources of.

◆ guac_client_free_buffer()

void guac_client_free_buffer ( guac_client * client,
guac_layer * layer )

Returns the given buffer to the pool of available buffers, such that it can be reused by any subsequent call to guac_client_allow_buffer().

Parameters
clientThe proxy client to return the buffer to.
layerThe buffer to return to the pool of available buffers.

◆ guac_client_free_layer()

void guac_client_free_layer ( guac_client * client,
guac_layer * layer )

Returns the given layer to the pool of available layers, such that it can be reused by any subsequent call to guac_client_allow_layer().

Parameters
clientThe proxy client to return the layer to.
layerThe buffer to return to the pool of available layer.

◆ guac_client_free_stream()

void guac_client_free_stream ( guac_client * client,
guac_stream * stream )

Returns the given stream to the pool of available streams, such that it can be reused by any subsequent call to guac_client_alloc_stream().

Parameters
clientThe client to return the stream to.
streamThe stream to return to the pool of available stream.

◆ guac_client_get_processing_lag()

int guac_client_get_processing_lag ( guac_client * client)

Calculates and returns the approximate processing lag experienced by the pool of users.

The processing lag is the difference in time between server and client due purely to data processing and excluding network delays.

Parameters
clientThe guac_client to calculate the processing lag of.
Returns
The approximate processing lag of the pool of users associated with the given guac_client, in milliseconds.

◆ guac_client_load_plugin()

int guac_client_load_plugin ( guac_client * client,
const char * protocol )

Initializes the given guac_client using the initialization routine provided by the plugin corresponding to the named protocol.

This will automatically invoke guac_client_init within the plugin for the given protocol.

Note that the connection will likely not be established until the first user (the "owner") is added to the client.

Parameters
clientThe guac_client to initialize.
protocolThe name of the protocol to use.
Returns
Zero if initialization was successful, non-zero otherwise.

◆ guac_client_log()

void guac_client_log ( guac_client * client,
guac_client_log_level level,
const char * format,
... )

Writes a message in the log used by the given client.

The logger used will normally be defined by guacd (or whichever program loads the proxy client) by setting the logging handlers of the client when it is loaded.

Parameters
clientThe proxy client logging this message.
levelThe level at which to log this message.
formatA printf-style format string to log.
...Arguments to use when filling the format string for printing.

◆ guac_client_owner_notify_join()

int guac_client_owner_notify_join ( guac_client * client,
guac_user * joiner )

Notifies the owner of the given client that a user has joined the connection, and returns zero if the message was sent successfully, or non-zero if the notification failed.

Parameters
clientThe Guacamole Client whose owner should be notified of a user joining the connection.
joinerThe Guacamole User who joined the connection.
Returns
Zero if the notification to the owner was sent successfully, or non-zero if an error occurred.

◆ guac_client_owner_notify_leave()

int guac_client_owner_notify_leave ( guac_client * client,
guac_user * quitter )

Notifies the owner of the given client that a user has left the connection, and returns zero if the message was sent successfully, or non-zero if the notification failed.

Parameters
clientThe Guacamole Client whose owner should be notified of a user leaving the connection.
quitterThe Guacamole User who left the connection.
Returns
Zero if the notification to the owner was sent successfully, or non-zero if an error occurred.

◆ guac_client_owner_send_required()

int guac_client_owner_send_required ( guac_client * client,
const char ** required )

Sends a request to the owner of the given guac_client for parameters required to continue the connection started by the client.

The function returns zero on success or non-zero on failure.

Parameters
clientThe client where additional connection parameters are required.
requiredThe NULL-terminated array of required parameters.
Returns
Zero on success, non-zero on failure.

◆ guac_client_owner_supports_msg()

int guac_client_owner_supports_msg ( guac_client * client)

Returns whether the owner of the given client supports the "msg" instruction, returning non-zero if the client owner does support the instruction, or zero if the owner does not.

Parameters
clientThe Guacamole client whose owner should be checked for supporting the "msg" instruction.
Returns
Non-zero if the owner of the given client supports the "msg" instruction, zero otherwise.

◆ guac_client_owner_supports_required()

int guac_client_owner_supports_required ( guac_client * client)

Returns whether the owner of the given client supports the "required" instruction, returning non-zero if the client owner does support the instruction, or zero if the owner does not.

Parameters
clientThe Guacamole client whose owner should be checked for supporting the "required" instruction.
Returns
Non-zero if the owner of the given client supports the "required" instruction, zero otherwise.

◆ guac_client_remove_user()

void guac_client_remove_user ( guac_client * client,
guac_user * user )

Removes the given user, removing the user from the internally-tracked list of connected users, and calling any appropriate leave handler.

Parameters
clientThe proxy client to return the buffer to.
userThe user to remove.

◆ guac_client_stop()

void guac_client_stop ( guac_client * client)

Signals the given client to stop gracefully.

This is a completely cooperative signal, and can be ignored by the client or the hosting daemon.

Parameters
clientThe proxy client to signal to stop.

◆ guac_client_stream_argv()

void guac_client_stream_argv ( guac_client * client,
guac_socket * socket,
const char * mimetype,
const char * name,
const char * value )

Streams the given connection parameter value over an argument value stream ("argv" instruction), exposing the current value of the named connection parameter to all users of the given client.

The argument value stream will be automatically allocated and freed.

Parameters
clientThe Guacamole client for which the argument value stream should be allocated.
socketThe socket over which instructions associated with the argument value stream should be sent.
mimetypeThe mimetype of the data within the connection parameter value being sent.
nameThe name of the connection parameter being sent.
valueThe current value of the connection parameter being sent.

◆ guac_client_stream_jpeg()

void guac_client_stream_jpeg ( guac_client * client,
guac_socket * socket,
guac_composite_mode mode,
const guac_layer * layer,
int x,
int y,
cairo_surface_t * surface,
int quality )

Streams the image data of the given surface over an image stream ("img" instruction) as JPEG-encoded data at the given quality.

The image stream will be automatically allocated and freed.

Parameters
clientThe Guacamole client for which the image stream should be allocated.
socketThe socket over which instructions associated with the image stream should be sent.
modeThe composite mode to use when rendering the image over the given layer.
layerThe destination layer.
xThe X coordinate of the upper-left corner of the destination rectangle within the given layer.
yThe Y coordinate of the upper-left corner of the destination rectangle within the given layer.
surfaceA Cairo surface containing the image data to be streamed.
qualityThe JPEG image quality, which must be an integer value between 0 and 100 inclusive. Larger values indicate improving quality at the expense of larger file size.

◆ guac_client_stream_png()

void guac_client_stream_png ( guac_client * client,
guac_socket * socket,
guac_composite_mode mode,
const guac_layer * layer,
int x,
int y,
cairo_surface_t * surface )

Streams the image data of the given surface over an image stream ("img" instruction) as PNG-encoded data.

The image stream will be automatically allocated and freed.

Parameters
clientThe Guacamole client for which the image stream should be allocated.
socketThe socket over which instructions associated with the image stream should be sent.
modeThe composite mode to use when rendering the image over the given layer.
layerThe destination layer.
xThe X coordinate of the upper-left corner of the destination rectangle within the given layer.
yThe Y coordinate of the upper-left corner of the destination rectangle within the given layer.
surfaceA Cairo surface containing the image data to be streamed.

◆ guac_client_stream_webp()

void guac_client_stream_webp ( guac_client * client,
guac_socket * socket,
guac_composite_mode mode,
const guac_layer * layer,
int x,
int y,
cairo_surface_t * surface,
int quality,
int lossless )

Streams the image data of the given surface over an image stream ("img" instruction) as WebP-encoded data at the given quality.

The image stream will be automatically allocated and freed. If the server does not support WebP, this function has no effect, so be sure to check the result of guac_client_supports_webp() prior to calling this function.

Parameters
clientThe Guacamole client for whom the image stream should be allocated.
socketThe socket over which instructions associated with the image stream should be sent.
modeThe composite mode to use when rendering the image over the given layer.
layerThe destination layer.
xThe X coordinate of the upper-left corner of the destination rectangle within the given layer.
yThe Y coordinate of the upper-left corner of the destination rectangle within the given layer.
surfaceA Cairo surface containing the image data to be streamed.
qualityThe WebP image quality, which must be an integer value between 0 and 100 inclusive. For lossy images, larger values indicate improving quality at the expense of larger file size. For lossless images, this dictates the quality of compression, with larger values producing smaller files at the expense of speed.
losslessZero to encode a lossy image, non-zero to encode losslessly.

◆ guac_client_supports_webp()

int guac_client_supports_webp ( guac_client * client)

Returns whether all users of the given client support WebP.

If any user does not support WebP, or the server cannot encode WebP images, zero is returned.

Parameters
clientThe Guacamole client whose users should be checked for WebP support.
Returns
Non-zero if the all users of the given client claim to support WebP and the server has been built with WebP support, zero otherwise.

◆ vguac_client_abort()

void vguac_client_abort ( guac_client * client,
guac_protocol_status status,
const char * format,
va_list ap )

Signals the given client to stop gracefully, while also signalling via the Guacamole protocol that an error has occurred.

Note that this is a completely cooperative signal, and can be ignored by the client or the hosting daemon. The message given will be logged to the system logs.

Parameters
clientThe proxy client to signal to stop.
statusThe status to send over the Guacamole protocol.
formatA printf-style format string to log.
apThe va_list containing the arguments to be used when filling the format string for printing.

◆ vguac_client_log()

void vguac_client_log ( guac_client * client,
guac_client_log_level level,
const char * format,
va_list ap )

Writes a message in the log used by the given client.

The logger used will normally be defined by guacd (or whichever program loads the proxy client) by setting the logging handlers of the client when it is loaded.

Parameters
clientThe proxy client logging this message.
levelThe level at which to log this message.
formatA printf-style format string to log.
apThe va_list containing the arguments to be used when filling the format string for printing.