/** * Returns the connection mask for a given connection. * * @param \Phergie\Irc\ConnectionInterface $connection * @return string */ protected function getConnectionMask(ConnectionInterface $connection) { return sprintf('%s!%s@%s', $connection->getNickname(), $connection->getUsername(), $connection->getServerHostname()); }
/** * There are certain incoming events that the client processes internally. * These functions are essential to the client-server relationship: for example, * updating the connection's stored nickname, responding to PING events, etc. * * Any user-level IRC functionality handled internally by the client * should be implemented here. * * @param array $message Parser output * @param \Phergie\Irc\Client\React\WriteStream $write Write stream * corresponding to the read stream on which the event occurred * @param \Phergie\Irc\ConnectionInterface $connection Connection on * which the event occurred */ protected function processInput(array $message, WriteStream $write, ConnectionInterface $connection) { switch ($message['command']) { // Update connection's internal nickname when changed case 'NICK': if ($connection->getNickname() === $message['nick']) { $connection->setNickname($message['params']['nickname']); } break; // Play client-server ping-pong // Play client-server ping-pong case 'PING': $write->ircPong($message['params']['server1']); break; } }
/** * Identifies the user to a server. * * @param \Phergie\Irc\ConnectionInterface $connection Connection on which * to identify the user * @param \Phergie\Irc\Client\React\WriteStream $writeStream Stream to * receive commands identifying the user */ protected function identifyUser(ConnectionInterface $connection, WriteStream $writeStream) { $password = $connection->getPassword(); if ($password) { $writeStream->ircPass($password); } $writeStream->ircUser($connection->getUsername(), $connection->getHostname(), $connection->getServername(), $connection->getRealname()); $writeStream->ircNick($connection->getNickname()); }