/[cvs]/nfo/php/libs/org.netfrag.glib/Data/Driver/RPC/Remote.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Data/Driver/RPC/Remote.php

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

revision 1.2 by joko, Thu Feb 13 00:42:44 2003 UTC revision 1.3 by joko, Thu Feb 13 21:51:29 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    --------------------------------------------------------------------------  ##    --------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.3  2003/02/13 21:51:29  joko
8    ##    + now can remember its connection-state
9    ##    + sub ping
10    ##
11  ##    Revision 1.2  2003/02/13 00:42:44  joko  ##    Revision 1.2  2003/02/13 00:42:44  joko
12  ##    +- renamed modules  ##    +- renamed modules
13  ##  ##
# Line 57  TODO: Line 61  TODO:
61  class Data_Driver_RPC_Remote extends DesignPattern_Logger {  class Data_Driver_RPC_Remote extends DesignPattern_Logger {
62    
63    var $configured;    var $configured;
64      var $meta;
65        
66    function Data_Driver_RPC_Remote($args = array()) {    function Data_Driver_RPC_Remote($args = array()) {
67        
68      parent::constructor();      parent::constructor();
69        
70      //print Dumper($this, $args);      //print Dumper($this, $args);
71        
72        global $Data_Driver_RPC_Remote_meta;
73        session_register_safe("Data_Driver_RPC_Remote_meta");
74        $this->meta = $Data_Driver_RPC_Remote_meta;
75    
76        if (!isset($this->meta[connected]) || $args[connect]) {
77          $this->meta[connected] = 1;
78        }
79        $this->_save_meta();
80    
81      if ($args['Host']) { $this->host = $args['Host']; }      if ($args['Host']) { $this->host = $args['Host']; }
82      if ($args['Port']) { $this->port = $args['Port']; }      if ($args['Port']) { $this->port = $args['Port']; }
83        
84      // check if host is valid      // check if host is valid
85      if (!$this->host) {      if (!$this->host) {
86        $this->_raiseException( "->constructor: attribute 'host' is empty, please check your settings");        $this->_raiseException( "->constructor: attribute 'host' is empty, please check your settings");
# Line 82  class Data_Driver_RPC_Remote extends Des Line 96  class Data_Driver_RPC_Remote extends Des
96            
97    }    }
98    
99      function _save_meta() {
100        global $Data_Driver_RPC_Remote_meta;
101        $Data_Driver_RPC_Remote_meta = $this->meta;
102      }
103    
104    function send($command, $data = "", $options = array()) {    function send($command, $data = "", $options = array()) {
105    
106        $this->log(get_class($this) . "->send: " . $command, PEAR_LOG_DEBUG);
107        
108        if (!$this->isConnected()) {
109          $this->_raiseException( "->send: not connected!");
110          return;
111        }
112        
113      // do 'encode' here and ...      // do 'encode' here and ...
114      if ($options[utf8]) {      if ($options[utf8]) {
115        $encoder = new Data_Encode($data);        $encoder = new Data_Encode($data);
# Line 99  class Data_Driver_RPC_Remote extends Des Line 126  class Data_Driver_RPC_Remote extends Des
126        return;        return;
127      }      }
128            
129        // populate options list - mostly for debugging purposes
130          $options_list = array();
131          foreach ($options as $key => $value) {
132            array_push($options_list, "$key=$value");
133          }
134    
135        $data_debug = $data;
136        if (is_array($data_debug)) { $data_debug = join(", ", $data_debug); }
137        $options_debug = join(", ", $options_list);
138        $this->log(get_class($this) . ": " . $command . "(" . $data_debug . ") [" . $options_debug . "]", PEAR_LOG_DEBUG);
139    
140      // trace      // trace
141        //print "call: $command<hr>";        //print "call: $command<hr>";
142        //print Dumper($data);        //print Dumper($data);
# Line 139  class Data_Driver_RPC_Remote extends Des Line 177  class Data_Driver_RPC_Remote extends Des
177            $encoder = new Data_Encode($data);            $encoder = new Data_Encode($data);
178            $encoder->toISO();            $encoder->toISO();
179          }          }
180            
181            $this->meta[connected] = 1;
182            $this->_save_meta();
183    
184          return $data;          return $data;
185        } else {        } else {
# Line 148  class Data_Driver_RPC_Remote extends Des Line 189  class Data_Driver_RPC_Remote extends Des
189    }    }
190        
191    function _raiseException($message) {    function _raiseException($message) {
192      $this->log(get_class($this) . $message, PEAR_LOG_CRIT);      $this->meta[connected] = 0;
193      //dprint(get_class($this) . $message);      $this->_save_meta();
194        $this->log(get_class($this) . $message, PEAR_LOG_ERR);
195      }
196      
197      function isConnected() {
198        return $this->meta[connected];
199      }
200      
201      function ping() {
202        $this->_call('ping');
203    }    }
204        
205  }  }

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

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