Migrate to ack, remove abort.

This commit is contained in:
Michael Jumper 2013-10-15 11:23:07 -07:00
parent b88749aedd
commit 3cf001116b
3 changed files with 27 additions and 26 deletions

View File

@ -141,7 +141,7 @@ int __guac_handle_file(guac_client* client, guac_instruction* instruction) {
guac_stream dummy_stream; guac_stream dummy_stream;
dummy_stream.index = stream_index; dummy_stream.index = stream_index;
guac_protocol_send_abort(client->socket, &dummy_stream, guac_protocol_send_ack(client->socket, &dummy_stream,
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER); "Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
return 0; return 0;
} }
@ -161,7 +161,7 @@ int __guac_handle_file(guac_client* client, guac_instruction* instruction) {
); );
/* Otherwise, abort */ /* Otherwise, abort */
guac_protocol_send_abort(client->socket, stream, guac_protocol_send_ack(client->socket, stream,
"File transfer unsupported", GUAC_PROTOCOL_STATUS_UNSUPPORTED); "File transfer unsupported", GUAC_PROTOCOL_STATUS_UNSUPPORTED);
return 0; return 0;
} }
@ -177,7 +177,7 @@ int __guac_handle_blob(guac_client* client, guac_instruction* instruction) {
guac_stream dummy_stream; guac_stream dummy_stream;
dummy_stream.index = stream_index; dummy_stream.index = stream_index;
guac_protocol_send_abort(client->socket, &dummy_stream, guac_protocol_send_ack(client->socket, &dummy_stream,
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER); "Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
return 0; return 0;
} }
@ -190,7 +190,7 @@ int __guac_handle_blob(guac_client* client, guac_instruction* instruction) {
guac_stream dummy_stream; guac_stream dummy_stream;
dummy_stream.index = stream_index; dummy_stream.index = stream_index;
guac_protocol_send_abort(client->socket, &dummy_stream, guac_protocol_send_ack(client->socket, &dummy_stream,
"Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER); "Invalid stream index", GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
return 0; return 0;
} }
@ -204,7 +204,7 @@ int __guac_handle_blob(guac_client* client, guac_instruction* instruction) {
} }
guac_protocol_send_abort(client->socket, stream, guac_protocol_send_ack(client->socket, stream,
"File transfer unsupported", GUAC_PROTOCOL_STATUS_UNSUPPORTED); "File transfer unsupported", GUAC_PROTOCOL_STATUS_UNSUPPORTED);
return 0; return 0;
} }
@ -223,7 +223,7 @@ int __guac_handle_end(guac_client* client, guac_instruction* instruction) {
guac_stream dummy_stream; guac_stream dummy_stream;
dummy_stream.index = stream_index; dummy_stream.index = stream_index;
guac_protocol_send_abort(client->socket, &dummy_stream, guac_protocol_send_ack(client->socket, &dummy_stream,
"Invalid stream index", "Invalid stream index",
GUAC_PROTOCOL_STATUS_INVALID_PARAMETER); GUAC_PROTOCOL_STATUS_INVALID_PARAMETER);
return 0; return 0;

View File

@ -229,6 +229,23 @@ typedef enum guac_line_join_style {
/* CONTROL INSTRUCTIONS */ /* CONTROL INSTRUCTIONS */
/**
* Sends an ack instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param stream The guac_stream associated with the operation this ack is
* acknowledging.
* @param error The human-readable description associated with the error or
* status update.
* @param status The status code related to the error or status.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_ack(guac_socket* socket, guac_stream* stream,
const char* error, guac_protocol_status status);
/** /**
* Sends an args instruction over the given guac_socket connection. * Sends an args instruction over the given guac_socket connection.
* *
@ -396,22 +413,6 @@ int guac_protocol_send_file(guac_socket* socket, const guac_stream* stream,
int guac_protocol_send_blob(guac_socket* socket, const guac_stream* stream, int guac_protocol_send_blob(guac_socket* socket, const guac_stream* stream,
void* data, int count); void* data, int count);
/**
* Sends an abort instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param stream The stream to use.
* @param reason The human-readable reason the stream is being aborted.
* @param status The status associated with the reason the stream being
* aborted.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_abort(guac_socket* socket, const guac_stream* stream,
const char* reason, guac_protocol_status status);
/** /**
* Sends an end instruction over the given guac_socket connection. * Sends an end instruction over the given guac_socket connection.
* *

View File

@ -355,17 +355,17 @@ int __guac_socket_write_length_png(guac_socket* socket, cairo_surface_t* surface
/* Protocol functions */ /* Protocol functions */
int guac_protocol_send_abort(guac_socket* socket, const guac_stream* stream, int guac_protocol_send_ack(guac_socket* socket, guac_stream* stream,
const char* reason, guac_protocol_status status) { const char* error, guac_protocol_status status) {
int ret_val; int ret_val;
guac_socket_instruction_begin(socket); guac_socket_instruction_begin(socket);
ret_val = ret_val =
guac_socket_write_string(socket, "5.abort,") guac_socket_write_string(socket, "3.ack,")
|| __guac_socket_write_length_int(socket, stream->index) || __guac_socket_write_length_int(socket, stream->index)
|| guac_socket_write_string(socket, ",") || guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_string(socket, reason) || __guac_socket_write_length_string(socket, error)
|| guac_socket_write_string(socket, ",") || guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, status) || __guac_socket_write_length_int(socket, status)
|| guac_socket_write_string(socket, ";"); || guac_socket_write_string(socket, ";");