Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\Identd\Worker Class Reference

A worker process for the Identification Protocol (RFC 1413). More...

+ Inheritance diagram for Erebot\Identd\Worker:

Public Member Functions

 __construct (\Erebot\Interfaces\Core $bot, $socket)
 
 __destruct ()
 Destructor.
 
 connect ()
 
 disconnect ($quitMessage=null)
 
 getBot ()
 
 getConfig ($chan)
 
 getIO ()
 
 getSocket ()
 
 isConnected ()
 
 process ()
 Processes commands queued in the input buffer.
 
 read ()
 
 write ()
 

Protected Member Functions

 handleMessage ($line)
 

Protected Attributes

 $bot
 A bot object implementing the Erebot::Interfaces::Core interface.
 
 $io
 I/O manager for the socket.
 
 $socket
 The underlying socket, represented as a stream.
 

Detailed Description

A worker process for the Identification Protocol (RFC 1413).

See also
http://www.ietf.org/rfc/rfc1413.txt

Definition at line 30 of file Worker.php.

Constructor & Destructor Documentation

Erebot\Identd\Worker::__construct ( \Erebot\Interfaces\Core  $bot,
  $socket 
)

Creates a worker object capable of handling a single identification request. As soon as the request has been handled and a response has been sent, this worker will destroy itself.

Parameters
Erebot::Interfaces::Core$botInstance of the bot to operate on.
resource$socketA socket connected to a client requesting an identification from our IdentD server.

Definition at line 57 of file Worker.php.

References Erebot\Identd\Worker\$bot, Erebot\Identd\Worker\$socket, and Erebot\LineIO\EOL_WIN.

Member Function Documentation

Erebot\Identd\Worker::connect ( )

Makes the actual connection to an IRC server, using the configuration data passed to the constructor.

Exceptions
Erebot::ConnectionFailureExceptionThrown whenever the bot fails to establish a connection to the given server.

Implements Erebot\Interfaces\Connection.

Definition at line 75 of file Worker.php.

Erebot\Identd\Worker::disconnect (   $quitMessage = null)

Disconnects the bot from that particular IRC server.

Parameters
string$quitMessage(optional) A message which will be visible by other users when the bot gets disconnected. If no message is given, the IrcConnector module is probed for its "quit_message" parameter. If no message is available, the bot quits with an empty string as its quit message.

Implements Erebot\Interfaces\Connection.

Definition at line 79 of file Worker.php.

Referenced by Erebot\Identd\Worker\process().

Erebot\Identd\Worker::getBot ( )

Returns the bot instance this connection is associated with.

Return values
Erebot::Interfaces::CoreAn instance of the core class (Erebot).

Implements Erebot\Interfaces\Connection.

Definition at line 193 of file Worker.php.

References Erebot\Identd\Worker\$bot.

Erebot\Identd\Worker::getConfig (   $chan)

Retrieves the configuration for a given channel.

Parameters
null | string$chanThe name of the IRC channel for which a configuration must be retrieved. If $chan is null, the configuration associated with this object is returned instead (an instance of the Erebot::Interfaces::Config::Server).
Return values
Erebot::Interfaces::Config::ChannelThe configuration for the given channel, if there is one.
Erebot::Interfaces::Config::ServerOtherwise, the configuration for the associated IRC server.
Exceptions
Erebot::NotFoundExceptionNo Erebot::Interfaces::Config::Channel object exists for the given channel.

Implements Erebot\Interfaces\Connection.

Definition at line 198 of file Worker.php.

Erebot\Identd\Worker::getIO ( )

Returns the object used to handle I/O (input/output) with this connection.

Note
Do not use this object directly unless you know what you're doing. Instead, use the methods from the appropriate interfaces: Erebot::Interfaces::SendingConnection for writing and Erebot::Interfaces::ReceivingConnection for reading.

Implements Erebot\Interfaces\Connection.

Definition at line 203 of file Worker.php.

References Erebot\Identd\Worker\$io.

Erebot\Identd\Worker::getSocket ( )

Returns the underlying transport implementation for this connection.

Return values
streamReturns this connection's socket, as a PHP stream.
Note
You generally don't need any sort of access to this stream, but it may be useful in cases where you need to do a select() on the connection.

Implements Erebot\Interfaces\Connection.

Definition at line 184 of file Worker.php.

References Erebot\Identd\Worker\$socket.

Erebot\Identd\Worker::handleMessage (   $line)
protected

Handles an IdentD request.

Parameters
string$lineIdentD request to handle.
Return values
stringMessage to send as the response to this request.
falseThe request was malformed.

Definition at line 123 of file Worker.php.

References Erebot\Identd\Worker\$socket.

Referenced by Erebot\Identd\Worker\process().

Erebot\Identd\Worker::isConnected ( )

Returns whether this connection object is currently connected to a server.

Return values
booltrue if the connection is really connected, false otherwise.

Implements Erebot\Interfaces\Connection.

Definition at line 179 of file Worker.php.

Erebot\Identd\Worker::read ( )

Processes data from the incoming buffer.

Once this method has been called, all lines awaiting processing in the incoming buffer have been transferred to the incoming FIFO. You must call Erebot::Connection::processQueuedData() after that in order to process the lines in the FIFO. This is done so that a throttling policy may be put in place if needed (eg. for an anti-flood system).

Implements Erebot\Interfaces\ReceivingConnection.

Definition at line 88 of file Worker.php.

Erebot\Identd\Worker::write ( )

Sends a single line of data from the outgoing FIFO to the underlying socket.

This method is misnamed, because it acts on a FIFO rather than on raw data. This method can be called multiple times (such as in a loop) to send all lines in the outgoing FIFO. This is done so that a throttling policy may be put in place if needed (eg. for an anti-flood system).

Implements Erebot\Interfaces\SendingConnection.

Definition at line 189 of file Worker.php.


The documentation for this class was generated from the following file: