/** * Constructor. * * @param \Hoa\Socket\Client $client Client. * @return void * @throws \Hoa\Socket\Exception */ public function __construct(Socket\Client $client) { parent::__construct($client); $this->getConnection()->setNodeName('\\Hoa\\Irc\\Node'); $this->_on = new Core\Event\Listener($this, ['open', 'join', 'message', 'private-message', 'mention', 'other-message', 'ping', 'kick', 'invite', 'error']); return; }
/** * Merge a connection into this one. * If we have two connections that must run at the same time, the * Hoa\Socket\Connection::consider() and Hoa\Socket\Connection::is() methods * are helpful but this whole class eases the merge of “high-level” * connections. * * @param \Hoa\Socket\Connection\Handler $other Connection to merge. * @return \Hoa\Socket\Connection\Handler */ public function merge(self $other) { $thisConnection = $this->getConnection(); $otherConnection = $other->getConnection(); $thisConnection->consider($otherConnection); if ($otherConnection instanceof Socket\Server) { $other->setConnection($thisConnection); } $this->_connections[] = $other; return $this; }
/** * Send a message to a specific node/connection. * * @param string $message Message. * @param \Hoa\Socket\Node $node Node (if null, current node). * @param int $opcode Opcode. * @param bool $end Whether it is the last frame of * the message. * @return void */ public function send($message, Socket\Node $node = null, $opcode = self::OPCODE_TEXT_FRAME, $end = true) { $send = parent::send($message, $node); if (null === $send) { return null; } return $send($opcode, $end); }