/** * Logs stats for a new response. * * @access private * @param HTTPResponse $response * @return void */ private function _log_response(HTTPResponse $response) { $ip = $this->request->get_remote_ip(); $response->set_default_headers(); // Tally up the total bytes sent. if ($this->request->get_controller_method() == 'websocket') { if (!isset(self::$_ws_bytes_sent[$ip])) { self::$_ws_bytes_sent[$ip] = 0; } self::$_ws_bytes_sent[$ip] += strlen($response->get_body()); } elseif ($this->request->get_controller_method() == 'long_polling') { if (!isset(self::$_lp_bytes_sent[$ip])) { self::$_lp_bytes_sent[$ip] = 0; } self::$_lp_bytes_sent[$ip] += strlen($response); } elseif ($this->request->get_controller_method() == 'short_polling') { if (!isset(self::$_sp_bytes_sent[$ip])) { self::$_sp_bytes_sent[$ip] = 0; } self::$_sp_bytes_sent[$ip] += strlen($response); } }
/** * Logs stats for a new response. * * @access private * @param HTTPResponse $response * @return void */ private function _log_response(HTTPResponse $response) { $response->set_default_headers(); // Tally up the total bytes sent. if ($this->request instanceof WSRequest) { self::$_ws_bytes_sent += strlen($response->get_body()); } else { self::$_lp_bytes_sent += strlen($response); } }
/** * Writes data to the client. If the method returns true, the connection should be * closed. * * @access public * @param HTTPResponse $chunk * @return boolean */ public function write(HTTPResponse $chunk) { $this->connection->write(chr(0) . $chunk->get_body() . chr(255)); return $chunk->get_status() != 200; }