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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show 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 <?
2 ## --------------------------------------------------------------------------
3 ## $Id: Remote.php,v 1.3 2002/12/19 01:59:37 jonen Exp $
4 ## --------------------------------------------------------------------------
5 ## $Log: Remote.php,v $
6 ## Revision 1.3 2002/12/19 01:59:37 jonen
7 ## + minor changes: coment debug prints
8 ##
9 ## Revision 1.2 2002/12/05 21:45:31 joko
10 ## + debugging
11 ##
12 ## Revision 1.1 2002/12/01 17:23:58 joko
13 ## + initial check-in
14 ##
15 ## 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 //print "new Remote<br>";
32 $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 function send($command, $data = "") {
39 //$encoder = new Text_Encode($data);
40 //$encoder->toUTF8();
41 return $this->call($command, $data, 1);
42 }
43
44 function call($command, $data = "", $decode = 0) {
45
46 // print "call: $command<hr>";
47
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 // TODO: redirect this error elsewhere!
59 print "RPC-error!<br>";
60 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