Class daemon_client

Description

StockManiac Client to talk to stockmaniacd via XML-RPC

Provide easy to use wrapper methods around the xmlrpc methods that the daemon exports. Thus this code must be kept in sync with the daemon!

It requires the 'xmlrpc' exptension loaded into PHP (take a look at http://xmlrpc-epi.sourceforge.net)

The goal is to have another layer between actual daemon public function calls and the GUI code. Since if the daemon changes I want one place to adjust the GUI. Also the GUI may need additional logic which does not fit well into the daemon... here is the correct place for that.

Located in /lib/daemon_client.class.php (line 53)


	
			
Variable Summary
 string $_error
 string $_host
 int $_port
 string $_uri
Method Summary
 object __construct ()
 string get_error ()
 array get_feed (int $id_news_feed)
 array get_stock (int $id_stock)
 array lookup_symbol (string $symbol, string $module)
 array parse_math_expressions (array $expressions)
 bool reload_feed (int $fid)
 bool reload_stock (int $sid)
 bool request_quote_update (int $sid)
 array solve_math_expressions (array $expressions, array $values)
 mixed _run (string $name, [array $args = array()])
 void _set_error (string $str)
Variables
string $_error = false (line 84)

error message, often human readable

string $_host = DAEMON_HOST (line 61)

daemon host name or address

  • access: protected
  • uses: DAEMON_HOST
int $_port = DAEMON_PORT (line 69)

port where the daemon is listening

  • access: protected
  • uses: DAEMON_PORT
string $_uri = '/' (line 76)

URL to be prepended on all requests.

  • access: protected
Methods
Constructor __construct (line 101)

constructor

automatically checks whether the daemon is reachable ATTENTION:

  • this makes object creation expensive, so use with care
  • on the other hand code using us must check for this once since all method calls will fails if the daemon is unvailable
  • error_reporting is turned off during the availability check as it confuses the test suite and errors are shown through our facilities anyway

  • todo: can we keep the socket and pass it to XMLRPC-EPI?
  • access: public
object __construct ()
get_error (line 156)

Return the error string or false if no error occured

string get_error ()
get_feed (line 179)

Return all information the daemon knows about a news feed The actual feed data will be ommited to save memory.

  • access: public
array get_feed (int $id_news_feed)
  • int $id_news_feed
get_stock (line 166)

Return all information the daemon knows about a security

  • access: public
array get_stock (int $id_stock)
  • int $id_stock
lookup_symbol (line 213)

Query a symbol from a quote source (Finance::Quote module)

  • access: public
array lookup_symbol (string $symbol, string $module)
  • string $symbol
  • string $module
parse_math_expressions (line 275)

Request the daemon to parse math $expressions.

Returns a list of variables contained in each expression. The returned list will have the same index as $expressions, but the order of elements is _not_ guaranteed. For example:

  1.   $expression array0=>'EBIT / Shares' );
would return
  1.   array0=>array[0]=>'EBIT'[1]=>'Shares') );
or
  1.   array0=>array[0]=>'Shares'[1]=>'EBIT' );

  • access: public
array parse_math_expressions (array $expressions)
  • array $expressions
reload_feed (line 224)

Request the daemon to reload a newsfeed record from the database, immediatelly.

  • access: public
bool reload_feed (int $fid)
  • int $fid
reload_stock (line 192)

Request the daemon to reload a security record from the database, immediatelly.

  • access: public
bool reload_stock (int $sid)
  • int $sid
request_quote_update (line 202)

Request immeditate quote update for security.

  • access: public
bool request_quote_update (int $sid)
  • int $sid
solve_math_expressions (line 248)

Request the daemon to solve math $expressions using data from $values

The indices of $expressions and $values are expected to match. For example: $expressions[0] will be solved using variable names and values from $values[0]. Suppose

  1.    $expressions[0'a * b'
$values[0] is expected to have indices for 'a' and 'b' like:
  1.    $values[0array('a'=>3'b'=>4)
The returned result array will be indexed like $expressions and $values.

array solve_math_expressions (array $expressions, array $values)
  • array $expressions
  • array $values
_run (line 126)

Request the StockManiac daemon to run a method. Return whatever the daemon returns.

  • access: protected
mixed _run (string $name, [array $args = array()])
  • string $name
  • array $args
_set_error (line 145)

Set the internal error string

void _set_error (string $str)
  • string $str

Documentation generated on Sun, 22 Aug 2010 11:20:14 +0200 by phpDocumentor 1.4.3