Properties

$tickInterval

$tickInterval : float

Interval in seconds between irc.tick events

Type

float

$dnsServer

$dnsServer : string

Type

string

Methods

getLoop()

getLoop() : \React\EventLoop\LoopInterface

Returns the event loop dependency, initializing it if needed.

Returns

\React\EventLoop\LoopInterface

setResolver()

setResolver(\React\Dns\Resolver\Resolver $resolver)

Sets the DNS Resolver.

Parameters

\React\Dns\Resolver\Resolver $resolver

getResolver()

getResolver() : \React\Dns\Resolver\Resolver

Get the DNS Resolver, if one isn't set in instance will be created.

Returns

\React\Dns\Resolver\Resolver

setDnsServer()

setDnsServer(string $dnsServer)

Set the DNS server to use when looking up IP's

Parameters

string $dnsServer

getDnsServer()

getDnsServer() : string

Returns the configured DNS server

Returns

string

setTickInterval()

setTickInterval(float $tickInterval)

Sets the interval in seconds between irc.tick events.

Parameters

float $tickInterval

getTickInterval()

getTickInterval() : float

Returns the interval in seconds between irc.tick events.

Returns

float

getLogger()

getLogger() : \Psr\Log\LoggerInterface

Returns a stream instance for logging data on the socket connection.

Returns

\Psr\Log\LoggerInterface

setLogger()

setLogger(\Psr\Log\LoggerInterface $logger)

Sets a logger for logging data on the socket connection.

Parameters

\Psr\Log\LoggerInterface $logger

addConnection()

addConnection(\Phergie\Irc\ConnectionInterface $connection)

Initializes an IRC connection.

Emits connect.before.each and connect.after.each events before and after connection attempts are established, respectively.

Emits a connect.error event if a connection attempt fails.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Metadata for connection to establish

Throws

\Phergie\Irc\Client\React\Exception

if unable to establish the connection

run()

run(\Phergie\Irc\ConnectionInterface|\Phergie\Irc\ConnectionInterface[] $connections)

Executes the event loop, which continues running until no active connections remain.

Parameters

\Phergie\Irc\ConnectionInterface|\Phergie\Irc\ConnectionInterface[] $connections

addTimer()

addTimer(\Phergie\Irc\Client\React\numeric $interval, callable $callback) : \React\Event\Timer\TimerInterface

Adds a one-time callback to execute after a specified amount of time has passed. Proxies to addTimer() implementation of the event loop implementation returned by getLoop().

Parameters

\Phergie\Irc\Client\React\numeric $interval

Number of seconds to wait before executing

   callback
callable $callback

Callback to execute

Returns

\React\Event\Timer\TimerInterface —

Added timer

addPeriodicTimer()

addPeriodicTimer(\Phergie\Irc\Client\React\numeric $interval, callable $callback) : \React\Event\Timer\TimerInterface

Adds a recurring callback to execute on a specified interval. Proxies to addPeriodTimer() implementation of the event loop implementation returned by getLoop().

Parameters

\Phergie\Irc\Client\React\numeric $interval

Number of seconds to wait between executions of callback

callable $callback

Callback to execute

Returns

\React\Event\Timer\TimerInterface —

Added timer

cancelTimer()

cancelTimer(\React\Event\Timer\TimerInterface $timer)

Cancels a specified timer created using addTimer() or addPeriodicTimer(). Proxies to the cancelTimer() implementation of the event loop implementation returned by getLoop().

Parameters

\React\Event\Timer\TimerInterface $timer

Timer returned by

   addTimer() or addPeriodicTimer()

isTimerActive()

isTimerActive(\React\Event\Timer\TimerInterface $timer) : boolean

Checks if a timer created using addTimer() or addPeriodicTimer() is active. Proxies to the isTimerActive() implementation of the event loop implementation returned by getLoop().

Parameters

\React\Event\Timer\TimerInterface $timer

Timer returned by

   addTimer() or addPeriodicTimer()

Returns

boolean —

TRUE if the specified timer is active, FALSE otherwise

getSocket()

getSocket(string $remote, array $context) : resource

Returns a socket configured for a specified remote.

Parameters

string $remote

Address to connect the socket to (e.g. tcp://irc.freenode.net:6667)

array $context

Context options for the socket

Throws

\Phergie\Irc\Client\React\Exception

if unable to connect to the specified remote

Returns

resource

getTransport()

getTransport(\Phergie\Irc\ConnectionInterface $connection) : string

Derives the transport for a given connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Returns

string —

Transport usable in the URI for a stream

getForceIpv4Flag()

getForceIpv4Flag(\Phergie\Irc\ConnectionInterface $connection) : boolean

Extracts the value of the force-ipv4 option from a given connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Returns

boolean —

TRUE to force use of IPv4, FALSE otherwise

getRemote()

getRemote(\Phergie\Irc\ConnectionInterface $connection) : string

Derives a remote for a given connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Returns

string —

Remote usable to establish a socket connection

getContext()

getContext(\Phergie\Irc\ConnectionInterface $connection) : array

Derives a set of socket context options for a given connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Returns

array —

Associative array of context option key-value pairs

getStream()

getStream(resource $socket) : \React\Stream\DuplexStreamInterface

Returns a stream for a socket connection.

Parameters

resource $socket

Socket for the connection to the server

Returns

\React\Stream\DuplexStreamInterface

addLogging()

addLogging(\Evenement\EventEmitter $emitter, \Phergie\Irc\ConnectionInterface $connection)

Adds an event listener to log data emitted by a stream.

Parameters

\Evenement\EventEmitter $emitter
\Phergie\Irc\ConnectionInterface $connection

Connection

   corresponding to the stream

getReadStream()

getReadStream(\Phergie\Irc\ConnectionInterface $connection) : \Phergie\Irc\Client\React\ReadStream

Returns a stream instance for parsing messages from the server and emitting them as events.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Connection

   corresponding to the read stream

Returns

\Phergie\Irc\Client\React\ReadStream

getReadCallback()

getReadCallback(\Phergie\Irc\Client\React\WriteStream $write, \Phergie\Irc\ConnectionInterface $connection) : callable

Returns a callback for proxying IRC events from the read stream to IRC listeners of the client.

Parameters

\Phergie\Irc\Client\React\WriteStream $write

Write stream

   corresponding to the read stream on which the event occurred
\Phergie\Irc\ConnectionInterface $connection

Connection on

   which the event occurred

Returns

callable

getWriteCallback()

getWriteCallback(\Phergie\Irc\Client\React\WriteStream $write, \Phergie\Irc\ConnectionInterface $connection) : callable

Returns a callback for proxying events from the write stream to IRC listeners of the client.

Parameters

\Phergie\Irc\Client\React\WriteStream $write

Write stream

   corresponding to the read stream on which the event occurred
\Phergie\Irc\ConnectionInterface $connection

Connection on which

   the event occurred

Returns

callable

getErrorCallback()

getErrorCallback(\Phergie\Irc\ConnectionInterface $connection) : callable

Returns a callback for proxying connection error events to listeners of the client.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Connection on which

   the error occurred

Returns

callable

getEndCallback()

getEndCallback(\React\Stream\DuplexStreamInterface $stream, \Phergie\Irc\ConnectionInterface $connection, \React\EventLoop\Timer\TimerInterface $timer) : callable

Returns a callback for when a connection is terminated, whether explicitly by the bot or server or as a result of loss of connectivity.

Parameters

\React\Stream\DuplexStreamInterface $stream

Stream representing the

   connection to the server
\Phergie\Irc\ConnectionInterface $connection

Terminated connection

\React\EventLoop\Timer\TimerInterface $timer

Timer used to handle

   asynchronously queued events on the connection, which must be
   cancelled

Returns

callable

getTickCallback()

getTickCallback(\Phergie\Irc\Client\React\WriteStream $write, \Phergie\Irc\ConnectionInterface $connection)

Returns a callback executed periodically to allow events to be sent asynchronously versus in response to received or sent events.

Parameters

\Phergie\Irc\Client\React\WriteStream $write

Stream used to

   send events to the server
\Phergie\Irc\ConnectionInterface $connection

Connection to

   receive the event

configureStreams()

configureStreams(\Phergie\Irc\ConnectionInterface $connection, \React\Stream\DuplexStreamInterface $stream, \Phergie\Irc\Client\React\WriteStream $write)

Configure streams to handle messages received from and sent to the server.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Metadata for the

   connection over which messages are being exchanged
\React\Stream\DuplexStreamInterface $stream

Stream representing the

   connection
   to the server
\Phergie\Irc\Client\React\WriteStream $write

Stream used to

   send events to the server

identifyUser()

identifyUser(\Phergie\Irc\ConnectionInterface $connection, \Phergie\Irc\Client\React\WriteStream $writeStream)

Identifies the user to a server.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Connection on which

   to identify the user
\Phergie\Irc\Client\React\WriteStream $writeStream

Stream to

   receive commands identifying the user

emitConnectionError()

emitConnectionError(\Exception $exception, \Phergie\Irc\ConnectionInterface $connection)

Emits a connection error event.

Parameters

\Exception $exception
\Phergie\Irc\ConnectionInterface $connection

addUnsecuredConnection()

addUnsecuredConnection(\Phergie\Irc\ConnectionInterface $connection)

Initializes an unsecured connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

getSecureConnector()

getSecureConnector() : \React\SocketClient\SecureConnector

Returns a connector for establishing SSL connections.

Returns

\React\SocketClient\SecureConnector

addSecureConnection()

addSecureConnection(\Phergie\Irc\ConnectionInterface $connection)

Initializes a secured connection.

Parameters

\Phergie\Irc\ConnectionInterface $connection

Throws

\Phergie\Irc\Client\React\Exception

if the SSL transport and

    forcing IPv4 usage are both enabled

initializeConnection()

initializeConnection(string $remote, \Phergie\Irc\ConnectionInterface $connection)

Initializes an added connection.

Parameters

string $remote
\Phergie\Irc\ConnectionInterface $connection