|
Erebot
latest
A modular IRC bot for PHP 5.3+
|
A class that provides a line-by-line reader. More...
Public Member Functions | |
| __construct ($eol, $socket=null) | |
| getEOL () | |
| getSocket () | |
| inReadQueue () | |
| inWriteQueue () | |
| pop () | |
| push ($line) | |
| read () | |
| setEOL ($eol) | |
| setSocket ($socket) | |
| write () | |
Public Attributes | |
| const | EOL_ANY = null |
| Universal line-ending mode (compatible with Windows, Mac and *nix). | |
| const | EOL_NEW_MAC = "\n" |
| New MacOS line-ending (MacOS > 9). | |
| const | EOL_OLD_MAC = "\r" |
| Old MacOS line-ending (MacOS <= 9). | |
| const | EOL_UNIX = "\n" |
| Unix line-ending. | |
| const | EOL_WIN = "\r\n" |
| Windows line-ending. | |
Protected Member Functions | |
| getLine () | |
Protected Attributes | |
| $eol | |
| Line-ending mode in use. | |
| $incomingData | |
| A raw buffer for incoming data. | |
| $rcvQueue | |
| A FIFO queue for incoming messages. | |
| $sndQueue | |
| A FIFO queue for outgoing messages. | |
| $socket | |
| The underlying socket, represented as a stream. | |
A class that provides a line-by-line reader.
Using this class, it is possible to read messages one line at a time simply by specifying the End-Of-Line (EOL) style in use by the protocol.
Definition at line 31 of file LineIO.php.
| Erebot\LineIO::__construct | ( | $eol, | |
$socket = null |
|||
| ) |
Constructs a new line-by-line reader.
| opaque | $eol | The type of line-endings to accept. This may be one of Erebot::LineIO::EOL_WIN, Erebot::LineIO::EOL_OLD_MAC, Erebot::LineIO::EOL_NEW_MAC, Erebot::LineIO::EOL_UNIX or Erebot::LineIO::EOL_ANY. |
| resource | $socket | (optional) The socket to operate on. |
Definition at line 85 of file LineIO.php.
| Erebot\LineIO::getEOL | ( | ) |
Returns the End-Of-Line (EOL) style currently used.
| opaque | EOL style currently in use. |
Definition at line 157 of file LineIO.php.
|
protected |
Retrieves a single line of text from the incoming buffer and puts it in the incoming FIFO.
| true | Whether a line could be fetched from the buffer. |
| false | ... or not. |
Definition at line 175 of file LineIO.php.
References Erebot\Utils\toUTF8().
| Erebot\LineIO::getSocket | ( | ) |
Returns the socket associated with this reader.
| resource | Socket associated with this reader, as set during this object's creation or the latest call to setSocket(). |
Definition at line 113 of file LineIO.php.
| Erebot\LineIO::inReadQueue | ( | ) |
Indicates whether there are lines in the input buffer waiting to be read.
| bool | Whether there are lines in the input buffer awaiting reading (true) or not (false). |
Definition at line 344 of file LineIO.php.
| Erebot\LineIO::inWriteQueue | ( | ) |
Indicates whether there are lines in the output buffer waiting to be written.
| bool | Whether there are lines in the output buffer awaiting writing (true) or not (false). |
Definition at line 359 of file LineIO.php.
| Erebot\LineIO::pop | ( | ) |
Returns a single line from the input buffer.
| string | A single line from the input buffer. |
| null | The input buffer did not contain any line. |
Definition at line 262 of file LineIO.php.
| Erebot\LineIO::push | ( | $line | ) |
Adds a given line to the outgoing FIFO.
| string | $line | The line of text to send. |
| Erebot::InvalidValueException | The $line contains invalid characters. |
Definition at line 279 of file LineIO.php.
| Erebot\LineIO::read | ( | ) |
Reads as many lines from the socket as possible.
| bool | true if lines were successfully read, false is returned whenever EOF is reached or if this method has been called while the socket was still uninitialized.. |
Definition at line 216 of file LineIO.php.
| Erebot\LineIO::setEOL | ( | $eol | ) |
Sets the End-Of-Line (EOL) style used to process lines.
| opaque | $eol | The type of line-endings to accept. This may be one of Erebot::LineIO::EOL_WIN, Erebot::LineIO::EOL_OLD_MAC, Erebot::LineIO::EOL_NEW_MAC, Erebot::LineIO::EOL_UNIX or Erebot::LineIO::EOL_ANY. |
Definition at line 130 of file LineIO.php.
| Erebot\LineIO::setSocket | ( | $socket | ) |
Sets the socket this line reader operates on.
| resource | $socket | The socket this reader will use from now on. |
Definition at line 97 of file LineIO.php.
| Erebot\LineIO::write | ( | ) |
Writes a single line from the output buffer to the socket.
| int | The number of bytes successfully written on the socket. |
| false | The connection was lost while trying to send the line or the output buffer was empty. |
Definition at line 306 of file LineIO.php.