/[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.6 - (show annotations)
Mon Feb 3 03:37:45 2003 UTC (21 years, 7 months ago) by jonen
Branch: MAIN
Changes since 1.5: +15 -12 lines
- removed unused argument  '$decode' at function '_call()'
+ added argument '$options=array()' at function '_call()'
  which will be passed to function '&decodeData()' for e.g. utf8 decoding
+ added  '$encoder->toISO()' at '&decodeData()', (re)moved from 'ProxyObject.php'

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

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