/[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.2 - (hide annotations)
Thu Dec 5 21:45:31 2002 UTC (21 years, 9 months ago) by joko
Branch: MAIN
Changes since 1.1: +12 -4 lines
+ debugging

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

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