aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML
diff options
context:
space:
mode:
Diffstat (limited to 'ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML')
-rw-r--r--ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm100
1 files changed, 0 insertions, 100 deletions
diff --git a/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm b/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm
deleted file mode 100644
index 5d9b388..0000000
--- a/ThirdParty/3Di/RegionMonitor/MonitorGUI/htdocs/XML/RPC.pm
+++ /dev/null
@@ -1,100 +0,0 @@
1package XML::RPC;
2
3use strict;
4use Carp;
5use RPC::XML;
6use RPC::XML::Parser;
7use RPC::XML::Client;
8
9sub new {
10 my ($this, $url) = @_;
11 my %fields = (
12 parser => new RPC::XML::Parser(),
13 url => $url,
14 );
15 return bless \%fields, $this;
16}
17
18sub receive {
19 my ($this, $xmldata, $handler) = @_;
20 my $response = undef;
21 eval {
22 my $request = $this->{parser}->parse($xmldata);
23 my @args = map {$_->value} @{$request->args};
24 $response = $handler->($request->{name}, @args);
25 };
26 if ($@) {
27 my %error = (
28 "error" => "ERROR",
29 "message" => $@,
30 );
31 $response = \%error;
32 }
33 if ( ref($response) eq "RPC::XML::response" ) {
34 return $response->as_string;
35 }
36 else {
37 return RPC::XML::response->new($response)->as_string;
38 }
39}
40
41sub call {
42 my ($this, $method_name, $param) = @_;
43 if (!$this->{url}) {
44 Carp::croak("XMLRPC: url not set for calling $method_name");
45 }
46 my $client = RPC::XML::Client->new($this->{url});
47 my $request_param = undef;
48 my $req = undef;
49 if (ref $param eq "ARRAY") {
50 $request_param = &_make_array_param($param);
51 $req = RPC::XML::request->new(
52 $method_name,
53 @$request_param,
54 );
55 } elsif (ref $param eq "HASH"){
56 $request_param = &_make_hash_param($param);
57 $req = RPC::XML::request->new(
58 $method_name,
59 $request_param,
60 );
61 } else {
62 Carp::croak("unexpected param type");
63 }
64 my $rpc_res = undef;
65 eval {
66 $rpc_res = $client->send_request($req);
67 };
68 if ($@) {
69 Carp::croak("request " . $this->{url} . "/" . $method_name . " failed. $@" );
70 }
71 if (ref($rpc_res) eq "RPC::XML::struct") {
72 my %res = map { $_ => $rpc_res->{$_}->value } keys %$rpc_res; # remember good perl !!
73 return \%res;
74 } elsif (ref($rpc_res) eq "RPC::XML::string") {
75 return $rpc_res->value;
76 } else {
77 return undef;
78 }
79}
80
81sub _make_array_param {
82 my $param = shift;
83 my @array_param = ();
84 foreach (@$param) {
85 push @array_param, RPC::XML::string->new($_); # @@@ only string type
86 }
87 return \@array_param;
88}
89
90sub _make_hash_param {
91 my $param = shift;
92 my %hash_param = ();
93 foreach (keys %$param) {
94 $hash_param{$_} = RPC::XML::string->new($param->{$_}); # @@@ only string type
95 }
96 return RPC::XML::struct->new(\%hash_param);
97}
98
991;
100