function __call($name, $arguments) { $request = new Request($name, $arguments); $this->sendMessage($request->__toString()); $result = $this->awaitResponse(); if (isset($result['error'])) { throw new \Exception($result['error']['message'], $result['error']['code']); } return $result['result']; }
public function listen() { $this->initServer(); while (true) { try { $message = $this->receiveMessage(); $object = Request::fromString($message); echo time() . " - " . $object->getMethod() . " " . json_encode($object->getParams()) . "\n"; $dispatcher = new RequestDispacher($object, $this->service); $response = $dispatcher->getResponse(); $this->postMessage($response->__toString()); } catch (\Exception $e) { } } }