WHen instantiating the client, can't get services because we havn't set credentials yet

This commit is contained in:
Isaac Connor 2019-10-03 17:36:57 -04:00
parent 783358c932
commit 5f702c1905
1 changed files with 21 additions and 34 deletions

View File

@ -74,40 +74,34 @@ my %soap_version_of :ATTR(:default<('1.1')>);
# =========================================================================
# private methods
sub service
{
sub service {
my ($self, $serviceName, $attr) = @_;
#print "service: " . $services_of{${$self}}{$serviceName}{$attr} . "\n";
# Please note that the Std::Class::Fast docs say not to use ident.
$services_of{ident $self}{$serviceName}{$attr};
}
sub set_service
{
sub set_service {
my ($self, $serviceName, $attr, $value) = @_;
$services_of{ident $self}{$serviceName}{$attr} = $value;
}
sub serializer
{
sub serializer {
my ($self) = @_;
$serializer_of{ident $self};
}
sub set_serializer
{
sub set_serializer {
my ($self, $serializer) = @_;
$serializer_of{ident $self} = $serializer;
}
sub soap_version
{
sub soap_version {
my ($self) = @_;
$soap_version_of{ident $self};
}
sub set_soap_version
{
sub set_soap_version {
my ($self, $soap_version) = @_;
$soap_version_of{ident $self} = $soap_version;
@ -188,11 +182,7 @@ sub http_digest {
};
}
# =========================================================================
sub BUILD
{
sub BUILD {
my ($self, $ident, $args_ref) = @_;
my $url_svc_device = $args_ref->{'url_svc_device'};
@ -214,12 +204,11 @@ sub BUILD
$services_of{$ident}{'device'} = { url => $url_svc_device, ep => $svc_device };
$self->get_service_urls();
# Can't, don't have credentials yet
#$self->get_service_urls();
}
sub get_users
{
sub get_users {
my ($self) = @_;
my $result = $self->service('device', 'ep')->GetUsers( { },, );
@ -228,8 +217,7 @@ sub get_users
# print $result . "\n";
}
sub create_user
{
sub create_user {
my ($self, $username, $password) = @_;
my $result = $self->service('device', 'ep')->CreateUsers( {
@ -245,11 +233,9 @@ sub create_user
die $result if not $result;
# print $result . "\n";
}
sub set_credentials
{
sub set_credentials {
my ($self, $username, $password, $create_if_not_exists) = @_;
# TODO: snyc device and client time
@ -271,10 +257,11 @@ sub set_credentials
}
# use this after set_credentials
sub create_services
{
sub create_services {
my ($self) = @_;
#$self->get_service_urls();
if ( defined $self->service('media', 'url') ) {
$self->set_service('media', 'ep', ONVIF::Media::Interfaces::Media::MediaPort->new({
proxy => $self->service('media', 'url'),
@ -291,11 +278,11 @@ sub create_services
}
}
sub get_endpoint
{
sub get_endpoint {
my ($self, $serviceType) = @_;
$self->service($serviceType, 'ep');
}
1;
__END__