_connection = $connection; return; } /** * Do the handshake. * * @param \Hoa\Http\Request $request Request. * @return void * @throws \Hoa\Websocket\Exception\BadProtocol */ abstract public function doHandshake(Http\Request $request); /** * Read a frame. * * @return array * @throws \Hoa\Websocket\Exception */ abstract public function readFrame(); /** * Write a frame. * * @param string $message Message. * @param int $opcode Opcode. * @param bool $end Whether it is the last frame of the message. * @param bool $mask Whether the message will be masked or not. * @return int * @throws \Hoa\Websocket\Exception */ abstract public function writeFrame( $message, $opcode = Websocket\Connection::OPCODE_TEXT_FRAME, $end = true, $mask = false ); /** * Send a message to a node (if not specified, current node). * * @param string $message Message. * @param int $opcode Opcode. * @param bool $end Whether it is the last frame of the message. * @param bool $mask Whether the message will be masked or not. * @return void */ abstract public function send( $message, $opcode = Websocket\Connection::OPCODE_TEXT_FRAME, $end = true, $mask = false ); /** * Close a specific node/connection. * * @param int $code Code (please, see * \Hoa\Websocket\Connection::CLOSE_* * constants). * @param string $reason Reason. * @param bool $mask Whether the message will be masked or not. * @return void */ abstract public function close( $code = Websocket\Connection::CLOSE_NORMAL, $reason = null, $mask = false ); /** * Get the socket connection. * * @return \Hoa\Socket\Connection */ protected function getConnection() { return $this->_connection; } }