X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmiracle%2Fmiracle_connection.c;h=30eef7a756ea4a6aeb86a8aa3e41108bc7978dfd;hb=529670db145a8731d56a8fc5fc43b8aa480f7f1f;hp=82a5b5913233ece076f3a6c4897396b09e0c4ea8;hpb=dafff01fba7ff4aa7d7640a7642231f2a985b8d2;p=melted diff --git a/src/miracle/miracle_connection.c b/src/miracle/miracle_connection.c index 82a5b59..30eef7a 100644 --- a/src/miracle/miracle_connection.c +++ b/src/miracle/miracle_connection.c @@ -201,6 +201,7 @@ void *parser_thread( void *arg ) { struct hostent *he; connection_t *connection = arg; + mlt_properties owner = connection->owner; char address[ 512 ]; char command[ 1024 ]; int fd = connection->fd; @@ -223,9 +224,52 @@ void *parser_thread( void *arg ) while( !error && connection_read( fd, command, 1024 ) ) { - if ( strncmp( command, "STATUS", 6 ) ) + response = NULL; + + if ( !strncmp( command, "PUSH ", 5 ) ) + { + char temp[ 20 ]; + int bytes; + char *buffer = NULL; + int total = 0; + mlt_service service = NULL; + + connection_read( fd, temp, 20 ); + bytes = atoi( temp ); + buffer = malloc( bytes + 1 ); + while ( total < bytes ) + { + int count = read( fd, buffer + total, bytes - total ); + if ( count >= 0 ) + total += count; + else + break; + } + buffer[ bytes ] = '\0'; + if ( bytes > 0 && total == bytes ) + { + if ( mlt_properties_get( owner, "push-parser-off" ) == 0 ) + { + service = ( mlt_service )mlt_factory_producer( "westley-xml", buffer ); + mlt_events_fire( owner, "push-received", &response, command, service, NULL ); + if ( response == NULL ) + response = valerie_parser_push( parser, command, service ); + } + else + { + response = valerie_parser_received( parser, command, buffer ); + } + } + error = connection_send( fd, response ); + valerie_response_close( response ); + mlt_service_close( service ); + free( buffer ); + } + else if ( strncmp( command, "STATUS", 6 ) ) { - response = valerie_parser_execute( parser, command ); + mlt_events_fire( owner, "command-received", &response, command, NULL ); + if ( response == NULL ) + response = valerie_parser_execute( parser, command ); miracle_log( LOG_INFO, "%s \"%s\" %d", address, command, valerie_response_get_error_code( response ) ); error = connection_send( fd, response ); valerie_response_close( response );