/** * Constructor * * @param BEAR_Ro $ro */ public function __construct(BEAR_Ro $ro) { /* @var $ro BEAR_Ro */ $this->code = $ro->getCode(); $this->header = $ro->getHeaders(); $this->body = $ro->getBody(); $this->links = $ro->getLinks(); $this->html = $ro->getHtml(); }
/** * データ送信 * * @param int $clientId クライアントID * @param string $method リクエストメソッド名 * @param BEAR_Ro $ro RO * * @return void */ public function sendData($clientId, $method, BEAR_Ro $ro) { $code = $ro->getCode(); $hearders = $ro->getHeaders(); if (isset($hearders['broadcast'])) { $this->_server->broadcastData($code . PHP_EOL, array($clientId)); $this->_server->broadcastData('Content-Type: text/php' . PHP_EOL, array($clientId)); $type = 'X-Socket-Type: broadcast' . PHP_EOL; $this->_server->broadcastData($type, array($clientId)); $this->_server->broadcastData(PHP_EOL, array($clientId)); $data = serialize($hearders['broadcast']) . PHP_EOL; $this->_server->broadcastData($data, array($clientId)); } $this->_server->sendData($clientId, $code . PHP_EOL); $this->_server->sendData($clientId, 'Content-Type: text/php' . PHP_EOL); $this->_server->sendData($clientId, PHP_EOL); $data = $ro->getBody(); $this->_server->sendData($clientId, serialize($data) . PHP_EOL); }