src/libguac/user-handshake.c
/**
 * This function loops through the received instructions during the handshake
 * with the client attempting to join the connection, and runs the handlers
 * for each of the opcodes, ending when the connect instruction is received.
 * Returns zero if the handshake completes successfully with the connect opcode,
 * or a non-zero value if an error occurs.
 * 
 * @param user
 *     The guac_user attempting to join the connection.
 * 
 * @param parser
 *     The parser used to examine the received data.
 * 
 * @param usec_timeout
 *     The timeout, in microseconds, for reading the instructions.
 * 
 * @return
 *     Zero if the handshake completes successfully with the connect opcode,
 *     or non-zero if an error occurs.
 */
This function loops through the received instructions during the handshake
with the client attempting to join the connection, and runs the handlers
for each of the opcodes, ending when the connect instruction is received.
Returns zero if the handshake completes successfully with the connect opcode,
or a non-zero value if an error occurs.

@param user
The guac_user attempting to join the connection.

@param parser
The parser used to examine the received data.

@param usec_timeout
The timeout, in microseconds, for reading the instructions.

@return
Zero if the handshake completes successfully with the connect opcode,
or non-zero if an error occurs.
This function loops through the received instructions during the handshake with the client attempting to join the connection and runs the handlers for each of the opcodes ending when the connect instruction is received . Returns zero if the handshake completes successfully with the connect opcode or a non - zero value if an error occurs . @param user The guac_user attempting to join the connection . @param parser The parser used to examine the received data . @param usec_timeout The timeout in microseconds for reading the instructions . @return Zero if the handshake completes successfully with the connect opcode or non - zero if an error occurs .
static int __guac_user_handshake(guac_user* user, guac_parser* parser,
        int usec_timeout) {
    guac_socket* socket = user->socket;
    while (guac_parser_read(parser, socket, usec_timeout) == 0) {
        if (strcmp(parser->opcode, "connect") == 0)
            return 0;
        guac_user_log(user, GUAC_LOG_DEBUG, "Processing instruction: %s",
                parser->opcode);
        if (__guac_user_call_opcode_handler(__guac_handshake_handler_map, user,
                parser->opcode, parser->argc, parser->argv)) {
            guac_user_log_handshake_failure(user);
            guac_user_log_guac_error(user, GUAC_LOG_DEBUG,
                    "Error handling instruction during handshake.");
            guac_user_log(user, GUAC_LOG_DEBUG, "Failed opcode: %s",
                    parser->opcode);
            guac_parser_free(parser);
            return 1;
        }
    }
    guac_user_log(user, GUAC_LOG_ERROR,
            "Handshake failed, \"connect\" instruction was not received.");
    return 1;
}
static int __guac_user_handshake ( guac_user * user , guac_parser * parser , int usec_timeout ) { guac_socket * socket = user -> socket ; while ( guac_parser_read ( parser , socket , usec_timeout ) == 0 ) { if ( strcmp ( parser -> opcode , " " ) == 0 ) return 0 ; guac_user_log ( user , GUAC_LOG_DEBUG , " " , parser -> opcode ) ; if ( __guac_user_call_opcode_handler ( __guac_handshake_handler_map , user , parser -> opcode , parser -> argc , parser -> argv ) ) { guac_user_log_handshake_failure ( user ) ; guac_user_log_guac_error ( user , GUAC_LOG_DEBUG , " " ) ; guac_user_log ( user , GUAC_LOG_DEBUG , " " , parser -> opcode ) ; guac_parser_free ( parser ) ; return 1 ; } } guac_user_log ( user , GUAC_LOG_ERROR , " \" \" " ) ; return 1 ; }
This function loops through the received instructions during the handshake
 with the client attempting to join the connection, and runs the handlers
 for each of the opcodes, ending when the connect instruction is received.
This function loops through the received instructions during the handshake with the client attempting to join the connection and runs the handlers for each of the opcodes ending when the connect instruction is received .
/* Handle each of the opcodes. */ /* If we receive the connect opcode, we're done. */ /* Run instruction handler for opcode with arguments. */ /* If we get here it's because we never got the connect instruction. */