/[cvs]/nfo/php/libs/org.netfrag.flib/Application/RPC/Remote.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.flib/Application/RPC/Remote.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Thu Dec 19 02:02:25 2002 UTC (21 years, 9 months ago) by jonen
Branch: MAIN
Changes since 1.3: +5 -2 lines
+ minor changes

1 joko 1.1 <?
2     ## --------------------------------------------------------------------------
3 jonen 1.4 ## $Id: Remote.php,v 1.3 2002/12/19 01:59:37 jonen Exp $
4 joko 1.1 ## --------------------------------------------------------------------------
5 joko 1.2 ## $Log: Remote.php,v $
6 jonen 1.4 ## Revision 1.3 2002/12/19 01:59:37 jonen
7     ## + minor changes: coment debug prints
8     ##
9 jonen 1.3 ## Revision 1.2 2002/12/05 21:45:31 joko
10     ## + debugging
11     ##
12 joko 1.2 ## Revision 1.1 2002/12/01 17:23:58 joko
13     ## + initial check-in
14     ##
15 joko 1.1 ## Revision 1.3 2002/12/01 06:22:57 cvsjoko
16     ## + minor update: now can use config defaults or given args
17     ##
18     ## Revision 1.2 2002/10/29 19:14:45 cvsjoko
19     ## - bugfix: dont' do utf8-encoding here
20     ##
21     ## Revision 1.1 2002/10/09 00:51:39 cvsjoko
22     ## + new
23     ##
24     ##
25     ## -------------------------------------------------------------------------
26    
27     class Remote {
28    
29     function Remote($args = array()) {
30     global $cfg;
31 joko 1.2 //print "new Remote<br>";
32 joko 1.1 $this->host = $cfg[rpcinfo][Host];
33     $this->port = $cfg[rpcinfo][Port];
34     if ($args['Host']) { $this->host = $args['Host']; }
35     if ($args['Port']) { $this->port = $args['Port']; }
36     }
37    
38 joko 1.2 function send($command, $data = "") {
39 joko 1.1 //$encoder = new Text_Encode($data);
40     //$encoder->toUTF8();
41     return $this->call($command, $data, 1);
42     }
43    
44 joko 1.2 function call($command, $data = "", $decode = 0) {
45    
46 jonen 1.4 // print "call: $command<hr>";
47 joko 1.1
48     // data
49     $data_enc = XML_RPC_encode($data);
50    
51     // message - request
52     $msg = new XML_RPC_Message($command);
53     $msg->addParam($data_enc);
54     // remote procedure call
55     $rpc = new XML_RPC_Client("/", $this->host, $this->port);
56     $rpc->setDebug(0);
57     if ( !$msg_response = $rpc->send($msg) ) {
58 joko 1.2 // TODO: redirect this error elsewhere!
59 jonen 1.3 print "RPC-error!<br>";
60 joko 1.1 return;
61     }
62     // message - response
63     $response_enc = $msg_response->value();
64    
65     // TODO: what's this? prematurely returning here should not be considered "stable"....
66     return $this->decodeData($response_enc);
67    
68     if ($decode) {
69     return $this->decodeData($response_enc);
70     } else {
71     return $response_enc;
72     }
73    
74     }
75    
76     function &decodeData(&$payload) {
77     //if (!is_object($payload)) { return; }
78     if ($payload) {
79     // data
80     $data = XML_RPC_decode($payload);
81     //print "data: " . dumpVar($response);
82     return $data;
83     } else {
84     //print "ERROR!<br>";
85     return 0;
86     }
87     }
88    
89     }
90    
91     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed