I am first doing a recovery test, and "perl upnp" exits with error:
Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.7/UPnP/ControlPoint.pm line 830.
Here is the code (trivial modification of the example):
use UPnP::ControlPoint;
my $cp = UPnP::ControlPoint->new;
my $search = $cp->searchByType("urn:schemas-upnp-org:device:MediaServer:1", &callback);
$cp->handle;
sub callback {
my ($search, $device, $action) = @_;
Hi
I've just installed gmediaserver from:
http://www.nongnu.org/gmediaserver/
I am first doing a recovery test, and "perl upnp" exits with error:
Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/lib/perl5/site_perl/5.8.7/UPnP/ControlPoint.pm line 830.
Here is the code (trivial modification of the example):
use UPnP::ControlPoint;
my $cp = UPnP::ControlPoint->new;
my $search = $cp->searchByType("urn:schemas-upnp-org:device:MediaServer:1", &callback);
$cp->handle;
sub callback {
my ($search, $device, $action) = @_;
if ($action eq 'deviceAdded') {
print("Device: " . $device->friendlyName . " added. Device contains:\n");
for my $service ($device->services) {
print("\tService: " . $service->serviceType . "\n");
}
}
elsif ($action eq 'deviceRemoved') {
print("Device: " . $device->friendlyName . " removed\n");
}
}
Thanks
Sorry for the incredibly late response. The callback passed to UPnP::ControlPoint::searchByType should be a code reference i.e.
my $search = $cp->searchByType("urn:schemas-upnp-org:device:MediaServer:1", \&callback);
You forgot the \ before &callback.