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 nowThis is the message on my log :
This is my code where i use SimpleAsyncHTTP :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.
Do you know what this error come from ?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"); } }
Thank a lot !
Results 1 to 10 of 90
Thread: SimpleAsyncHTTP Problem
-
2015-03-13, 05:58 #1
- Join Date
- Mar 2014
- Posts
- 234
SimpleAsyncHTTP Problem
-
2015-03-15, 22:11 #2
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
-
2015-03-16, 01:19 #3
- 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
-
2015-03-16, 01:54 #4
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
-
2015-03-16, 04:39 #5
- 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, });
-
2015-03-16, 04:58 #6
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
-
2015-03-16, 05:02 #7
SimpleAsyncHTTP Problem
BTW: there's a bit of documentation at the bottom of
Slim/Networking/SimpleAsyncHTTP.pm.
--
Michael
-
2015-03-16, 05:15 #8
- Join Date
- Mar 2014
- Posts
- 234
Ok so i try :
Code:sub commandCallback { my $http = Slim::Networking::SimpleAsyncHTTP->new(\&gotErrorViaHTTP, { client => $client, }); } sub gotErrorViaHTTP { }
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.
-
2015-03-28, 02:29 #9
- 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 okLast edited by Hydro; 2015-03-28 at 02:37.
-
2015-03-28, 22:27 #10
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