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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by joko, Thu Dec 5 21:45:31 2002 UTC revision 1.6 by jonen, Mon Feb 3 03:37:45 2003 UTC
# Line 3  Line 3 
3  ##    $Id$  ##    $Id$
4  ##    --------------------------------------------------------------------------  ##    --------------------------------------------------------------------------
5  ##    $Log$  ##    $Log$
6    ##    Revision 1.6  2003/02/03 03:37:45  jonen
7    ##    - removed unused argument  '$decode' at function '_call()'
8    ##    + added argument '$options=array()' at function '_call()'
9    ##      which will be passed to function '&decodeData()' for e.g. utf8 decoding
10    ##    + added  '$encoder->toISO()' at '&decodeData()', (re)moved from 'ProxyObject.php'
11    ##
12    ##    Revision 1.5  2002/12/22 13:24:09  jonen
13    ##    + added utf8 encoding at 'send()' toggled by option
14    ##
15    ##    Revision 1.4  2002/12/19 02:02:25  jonen
16    ##    + minor changes
17    ##
18    ##    Revision 1.3  2002/12/19 01:59:37  jonen
19    ##    + minor changes: coment debug prints
20    ##
21  ##    Revision 1.2  2002/12/05 21:45:31  joko  ##    Revision 1.2  2002/12/05 21:45:31  joko
22  ##    + debugging  ##    + debugging
23  ##  ##
# Line 32  class Remote { Line 47  class Remote {
47      if ($args['Port']) { $this->port = $args['Port']; }      if ($args['Port']) { $this->port = $args['Port']; }
48    }    }
49    
50    function send($command, $data = "") {    function send($command, $data = "", $options = array()) {
51      //$encoder = new Text_Encode($data);      // do 'encode' here and ...
52      //$encoder->toUTF8();      if ($options[utf8]) {
53      return $this->call($command, $data, 1);        $encoder = new TextEncode($data);
54          $encoder->toUTF8();
55        }
56        // call '_call' with 'decode'
57        return $this->_call($command, $data, $options);
58    }    }
59    
60    function call($command, $data = "", $decode = 0) {    function _call($command, $data = "", $options = array() ) {
61    
62  //print "call: <hr>";     //print "call: $command<hr>";
63    
64    // print Dumper($data);
65    
66      // data      // data
67        $data_enc = XML_RPC_encode($data);        $data_enc = XML_RPC_encode($data);
# Line 48  class Remote { Line 69  class Remote {
69      // message - request      // message - request
70        $msg = new XML_RPC_Message($command);        $msg = new XML_RPC_Message($command);
71        $msg->addParam($data_enc);        $msg->addParam($data_enc);
72    //print htmlentities($msg->serialize());
73      // remote procedure call      // remote procedure call
74        $rpc = new XML_RPC_Client("/", $this->host, $this->port);        $rpc = new XML_RPC_Client("/", $this->host, $this->port);
75        $rpc->setDebug(0);        $rpc->setDebug(0);
76        if ( !$msg_response = $rpc->send($msg) ) {        if ( !$msg_response = $rpc->send($msg) ) {
77          // TODO: redirect this error elsewhere!          // TODO: redirect this error elsewhere!
78          //print "RPC-error!<br>";          print "RPC-error!<br>";
79          return;          return;
80        }        }
81      // message - response      // message - response
82        $response_enc = $msg_response->value();        $response_enc = $msg_response->value();
83    
84        // TODO: what's this? prematurely returning here should not be considered "stable"....        // TODO: what's this? prematurely returning here should not be considered "stable"....
85        return $this->decodeData($response_enc);        return $this->decodeData($response_enc, $options);
   
     if ($decode) {  
       return $this->decodeData($response_enc);  
     } else {  
       return $response_enc;  
     }  
       
86    }    }
87        
88    function &decodeData(&$payload) {    function &decodeData(&$payload, $options = array() ) {
89      //if (!is_object($payload)) { return; }      //if (!is_object($payload)) { return; }
90        if ($payload) {        if ($payload) {
91      // data      // data
92          $data = XML_RPC_decode($payload);          $data = XML_RPC_decode($payload);
93          //print "data: " . dumpVar($response);          //print "data: " . dumpVar($response);
94    
95            //  decode UTF8 to ISO if wanted
96            if($options[utf8]) {
97              $encoder = new TextEncode($data);
98              $encoder->toISO();
99            }
100    
101          return $data;          return $data;
102        } else {        } else {
103          //print "ERROR!<br>";          //print "ERROR!<br>";

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.6

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