Home of the Squeezebox™ & Transporter® network music players.
Page 1 of 9 123 ... LastLast
Results 1 to 10 of 90
  1. #1
    Senior Member
    Join Date
    Mar 2014
    Posts
    234

    SimpleAsyncHTTP Problem

    Hi

    I write a plugin for my home automation software and everything worked fine.

    But i change my computer and i reinstall LMS on the new one and copy the plugin folder to the new LMS installation.

    Nothing work now This is the message on my log :

    Code:
    [15-03-13 13:40:15.6810] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    [15-03-13 13:40:15.6822] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    [15-03-13 13:40:27.0805] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    This is my code where i use SimpleAsyncHTTP :

    Code:
    sub handlePlayStop {
    	my $client = shift;
    
    	
    	
    	my $iPower = $client->power();
    	
    	
    					my $mac = ref($client) ? $client->macaddress() : $client;
    
    	if ($iPower == 1){
    my $http = Slim::Networking::SimpleAsyncHTTP->new({
                            client => $client, 
                            
                    });
    
            $http->post("$jeedomipaddress/core/api/jeeApi.php?api=$jeedomapi&type=squeezebox&adress=$mac&logicalId=statut&value=Stop"); 		
    	}
    	else{
    my $http = Slim::Networking::SimpleAsyncHTTP->new({
                            client => $client, 
                            
                    });
    
            $http->post("$jeedomipaddress/core/api/jeeApi.php?api=$jeedomapi&type=squeezebox&adress=$mac&logicalId=statut&value=Off");
    	}
    
    
    }
    Do you know what this error come from ?

    Thank a lot !

  2. #2
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,324

    SimpleAsyncHTTP Problem

    > Code:
    > --------------------
    > [15-03-13 13:40:15.6810] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    > [15-03-13 13:40:15.6822] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    > [15-03-13 13:40:27.0805] Slim::Control::Request::notify (2085) Error: Failed notify: Can't use string ("") as a subroutine ref while "strict refs" in use at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.
    > --------------------


    Your call to Slim::Networking::SimpleAsyncHTTP->new needs to pass
    callbacks for success and failure cases. Which you don't give.

    --

    Michael

  3. #3
    Senior Member
    Join Date
    Mar 2014
    Posts
    234
    So why it worked before ?

    I don't find how to make callbacks ? Sorry i'm not very good at coding

  4. #4
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,324

    SimpleAsyncHTTP Problem

    > So why it worked before ?

    I'm wondering, too.

    > I don't find how to make callbacks ? Sorry i'm not very good at coding


    Checkout the many places where SimpleAsyncHTTP is being used. In the
    simplest case you might just pass it an empty call: sub {}. But it's a
    good idea to have a callback check whether your call succeeded or not.

    --

    Michael

  5. #5
    Senior Member
    Join Date
    Mar 2014
    Posts
    234
    For example i use :

    Code:
    	my $http = Slim::Networking::SimpleAsyncHTTP->new(\&getChartLyricsResponse, \&gotErrorViaHTTP, {
    			client => $client, 
    			params => $params,
    			track => $track,
    			trackTitle => $trackTitle,
    			albumTitle => $albumTitle,
    			artistName => $artistName,
    			
    		});
    What is the callback in this code ? \&getChartLyricsResponse, \&gotErrorViaHTTP, ?

  6. #6
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,324

    SimpleAsyncHTTP Problem

    > What is the callback in this code ? \&getChartLyricsResponse,
    > \&gotErrorViaHTTP, ?


    Yes, these are functions defined somewhere in the code which will be
    called on success or failure respectively.

    --

    Michael

  7. #7
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,324

    SimpleAsyncHTTP Problem

    BTW: there's a bit of documentation at the bottom of
    Slim/Networking/SimpleAsyncHTTP.pm.

    --

    Michael

  8. #8
    Senior Member
    Join Date
    Mar 2014
    Posts
    234
    Ok so i try :

    Code:
    sub commandCallback {
    
    my $http = Slim::Networking::SimpleAsyncHTTP->new(\&gotErrorViaHTTP, {
                            client => $client, 
                            
                    });
    
    }
    
    sub gotErrorViaHTTP {
            
    }
    I've got a new error :

    Code:
    [15-03-16 13:12:50.4812] Slim::Control::Request::notify (2085) Error: Failed notify: Not a CODE reference at /<C:\PROGRA~2\SQUEEZ~1\server\SQUEEZ~3.EXE>Slim/Networking/SimpleAsyncHTTP.pm line 239.

  9. #9
    Senior Member
    Join Date
    Mar 2014
    Posts
    234
    Ok so i add both error and validate callback and no more error message. But it didn't work

    Can i print into log the http request ?

    I try : $log->error("Couldn't find requested entry: $jeedomapi $jeedomipaddress $mac $iVolume"); and every data is ok
    Last edited by Hydro; 2015-03-28 at 02:37.

  10. #10
    Babelfish's Best Boy mherger's Avatar
    Join Date
    Apr 2005
    Location
    Switzerland
    Posts
    20,324

    SimpleAsyncHTTP Problem

    Please check some of the many calls in the code. There are lots of
    examples of how this works. Without more information about your code and
    what you want to achieve it's really hard to be of any more help. What's
    your code looking like? What result are you expecting? What are you getting?

    You can always "print Data:ump::dump($httpRequest)" in one of the
    callbacks to get more information about the call. $httpRequest is the
    first parameter sent to the callbacks.

    --

    Michael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •