Net::U...ervice(3pm)

πŸ“¦
version 1.4.6 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::UPnP::Service β€” the Perl extension for UPnP, bestie edition πŸ’–

okay so you found Net::UPnP::Service(3pm) in the User Contributed Perl Documentation and you're like "what is this" β€” don't worry, I got you. This whole package is the object that represents a UPnP service. That's it, that's the vibe. ✨


🌸 NAME 🌸

Net::UPnP::Service β€” a Perl extension for UPnP. iconic, honestly.


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole lil' journey, copied exactly so you can literally paste it and go:

use Net::UPnP::ControlPoint;

my $obj = Net::UPnP::ControlPoint->new();

@dev_list = $obj->search(st =>'upnp:rootdevice', mx => 3);

$devNum= 0;
foreach $dev (@dev_list) {
    $device_type = $dev->getdevicetype();
    if  ($device_type ne 'urn:schemas-upnp-org:device:MediaServer:1') {
        next;
    }
    print "[$devNum] : " . $dev->getfriendlyname() . "\n";
    unless ($dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1')) {
        next;
    }
    $condir_service = $dev->getservicebyname('urn:schemas-upnp-org:service:ContentDirectory:1');
    unless (defined(condir_service)) {
        next;
    }
    %action_in_arg = (
            'ObjectID' => 0,
            'BrowseFlag' => 'BrowseDirectChildren',
            'Filter' => '*',
            'StartingIndex' => 0,
            'RequestedCount' => 0,
            'SortCriteria' => '',
        );
    $action_res = $condir_service->postcontrol('Browse', \%action_in_arg);
    unless ($action_res->getstatuscode() == 200) {
        next;
    }
    $actrion_out_arg = $action_res->getargumentlist();
    unless ($actrion_out_arg->{'Result'}) {
        next;
    }
    $result = $actrion_out_arg->{'Result'};
    while ($result =~ m/<dc:title>(.*?)<\/dc:title>/sgi) {
        print "\t$1\n";
    }
    $devNum++;
}

(yes $actrion_out_arg is spelled like that in the source, and yes we are keeping it exactly, no cap 🫢)


🌈 DESCRIPTION 🌈

The package is used a object of UPnP service. πŸ’…

So basically: you've got a service on some UPnP device out there in the network wild, and this object is your little handle on it. Your main character entry point, fr fr.


πŸ‘‘ METHODS πŸ‘‘

getdevice β€” get the device

$description = $service->getdevice();

Get the parent device of the service. Your service's mom, basically. πŸŽ€

getdevicedescription β€” get the service description of the device description

$description = $service->getdevicedescription(
                            name => $name # undef
                         );

Get the service description of the device description. ✨

The function returns the all description when the name parameter is not specified, otherwise return a value the specified name. So: no name β†’ you get everything, name β†’ you get just that one thing. lowkey perfect.

getservicetype β€” get the service type

$service_type = $service->getservicetype();

Get the service type. πŸ¦‹

getserviceid β€” get the service id

$service_id = $service->getserviceid();

Get the service id. πŸ“

postaction β€” post a action control

$action_res = $service->postcontrol($action_name, \%action_arg);

Post a action control to the device, and return Net::UPnP::ActionResponse. πŸ”₯

⚠️ okay listen: the method was renamed from postcontrol(), but the old name is deprecated. so like… use the new one, bestie, don't be out here calling the deprecated name. πŸ™ˆ

postquery β€” post a query control

$query_res = $service->postcontrol($var_name);

Post a query control to the device, and return Net::UPnP::QueryResponse. πŸ’œ


πŸ’« SEE ALSO πŸ’«

  • Net::UPnP::ActionResponse

go read that one next, iykyk. πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

Satoshi Konno <skonno@cybergarage.org>

CyberGarage <http://www.cybergarage.org>


Copyright (C) 2005 by Satoshi Konno

It may be used, redistributed, and/or modified under the terms of BSD License. slay.


and that's the whole page, bestie!! πŸ’– this one's from perl v5.36.0, dated 2022-12-06, and it lives under Net::U...ervice(3pm) in the User Contributed Perl Documentation β€” mwah, go forth and browse those ContentDirectory titles. 🫢✨🌸

πŸ“¦ where this page comes from