Refactor creation of client to NOT require plugin.
This commit is contained in:
parent
928f3c5457
commit
6d5c9b6dde
@ -470,23 +470,25 @@ guac_client_plugin* guac_client_plugin_open(const char* protocol);
|
|||||||
int guac_client_plugin_close(guac_client_plugin* plugin);
|
int guac_client_plugin_close(guac_client_plugin* plugin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize and return a new guac_client. The pluggable client will be
|
* Initializes the given guac_client using the initialization routing provided
|
||||||
* initialized using the arguments provided.
|
* by the given guac_client_plugin.
|
||||||
*
|
*
|
||||||
* @param plugin The client plugin to use to create the new client.
|
* @param client The guac_client to initialize.
|
||||||
* @param socket The guac_socket the client should use for communication.
|
* @param plugin The client plugin to use to initialize the new client.
|
||||||
* @param argc The number of arguments being passed to the client.
|
* @param argc The number of arguments being passed to the client.
|
||||||
* @param argv All arguments to be passed to the client.
|
* @param argv All arguments to be passed to the client.
|
||||||
* @param log_info_handler Info logging handler to provide to the client before
|
* @return Zero if initialization was successful, non-zero otherwise.
|
||||||
* initializing.
|
|
||||||
* @param log_error_handler Error logging handler to provide to the client
|
|
||||||
* before initializing.
|
|
||||||
* @return A pointer to the newly initialized client.
|
|
||||||
*/
|
*/
|
||||||
guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin,
|
int guac_client_init(guac_client* client,
|
||||||
guac_socket* socket, int argc, char** argv,
|
guac_client_plugin* plugin, int argc, char** argv);
|
||||||
guac_client_log_handler* log_info_handler,
|
|
||||||
guac_client_log_handler* log_error_handler);
|
/**
|
||||||
|
* Returns a new, barebones guac_client. This new guac_client has no handlers
|
||||||
|
* set, but is otherwise usable.
|
||||||
|
*
|
||||||
|
* @return A pointer to the new client.
|
||||||
|
*/
|
||||||
|
guac_client* guac_client_alloc();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free all resources associated with the given client.
|
* Free all resources associated with the given client.
|
||||||
|
@ -237,10 +237,14 @@ int guac_client_plugin_close(guac_client_plugin* plugin) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin,
|
int guac_client_init(guac_client* client,
|
||||||
guac_socket* socket, int argc, char** argv,
|
guac_client_plugin* plugin, int argc, char** argv) {
|
||||||
guac_client_log_handler* log_info_handler,
|
|
||||||
guac_client_log_handler* log_error_handler) {
|
return plugin->init_handler(client, argc, argv);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
guac_client* guac_client_alloc() {
|
||||||
|
|
||||||
/* Allocate new client */
|
/* Allocate new client */
|
||||||
guac_client* client = malloc(sizeof(guac_client));
|
guac_client* client = malloc(sizeof(guac_client));
|
||||||
@ -253,7 +257,6 @@ guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin,
|
|||||||
/* Init new client */
|
/* Init new client */
|
||||||
memset(client, 0, sizeof(guac_client));
|
memset(client, 0, sizeof(guac_client));
|
||||||
|
|
||||||
client->socket = socket;
|
|
||||||
client->last_received_timestamp =
|
client->last_received_timestamp =
|
||||||
client->last_sent_timestamp = guac_protocol_get_timestamp();
|
client->last_sent_timestamp = guac_protocol_get_timestamp();
|
||||||
|
|
||||||
@ -266,15 +269,6 @@ guac_client* guac_client_plugin_get_client(guac_client_plugin* plugin,
|
|||||||
client->__next_buffer_index = -1;
|
client->__next_buffer_index = -1;
|
||||||
client->__next_layer_index = 1;
|
client->__next_layer_index = 1;
|
||||||
|
|
||||||
/* Set up logging in client */
|
|
||||||
client->log_info_handler = log_info_handler;
|
|
||||||
client->log_error_handler = log_error_handler;
|
|
||||||
|
|
||||||
if (plugin->init_handler(client, argc, argv) != 0) {
|
|
||||||
free(client);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user