Example #1
0
 public function renderTest()
 {
     $client = new Lightbulb\Json\Rpc2\Client('http://localhost/nette/endpoint');
     // Call functions that are binded in renderDefault method
     $result = $client->myTest->someFunc($param1, $param2);
     $result = $client->myFunction($param1, $param2);
     $result = $client->myTestHandler->myFunc();
     $result = $client->myStaticHandler($param);
     // $result always contain as per the RFC either:
     var_dump($result->result);
     // Or an error if there has been some
     var_dump($result->error);
 }
Example #2
0
<pre>
<?php 
/**
 * Available methods:
 * - notify
 * - echo
 * - math.sum
 * - math2.special.substract
 */
require_once __DIR__ . '/../lib/Client.php';
// Instantiate and call
$client = new Lightbulb\Json\Rpc2\Client('http://github.loc/JSONRpc2/tests/serverTest.php');
//$client->debug = true;
echo 'call $client->notify();<br />';
var_dump($client->notify());
echo '<hr />';
echo 'call $client->echo("something");<br />';
var_dump($client->echo('something'));
echo '<hr />';
echo 'call $client->math->sum(25, 30, 45);<br />';
var_dump($client->math->sum(25, 30, 45));
echo '<hr />';
echo 'call $client->math2->special->substract(25, 5, 10);<br />';
var_dump($client->math2->special->substract(25, 5, 10));
echo '<hr />';
echo 'call $client->__call("math2.special.substract", array(25, 5, 10));<br />';
var_dump($client->__call('math2.special.substract', array(25, 5, 10)));
Example #3
0
 /**
  * Handles generic send of the payload
  */
 public function handleSendJson($method)
 {
     // Prepare the request
     $args = $this->_mapJson($_POST, $_POST);
     // Showtime!
     $client = new \Lightbulb\Json\Rpc2\Client($this->endpoint);
     $client->_debug();
     $return = $client->__call($method, $args);
     // Assign into the template
     $this->template->jsonRequest = \Lightbulb\Json\Rpc2\Client::formatJson($client->_getRequest());
     $this->template->jsonResponse = \Lightbulb\Json\Rpc2\Client::formatJson($client->_getResponse());
     $this->template->parsedResponse = $return;
 }