yf_wrapper_pubsub classCore PUB/SUB events wrapper.
| File | plugins/pubsub/classes/yf_wrapper_pubsub.class.php |
|---|---|
| Use | _class('wrapper_pubsub') |
A site sets them in its config with $PROJECT_CONF['wrapper_pubsub']['NAME'] = ...;
| Property | Default | Description |
|---|---|---|
$_connection |
null |
|
$driver |
'redis' |
public function conf($params = [])
Configure driver.
public function conf($params = [])
{
! $this->_connection && $this->connect();
return $this->_connection->conf($params);
}
public function connect()
Do connect to the low level driver.
public function connect()
{
if ( ! $this->_connection) {
$this->_connection = _class('pubsub_driver_' . $this->driver, 'classes/pubsub/');
$this->_connection->connect();
}
return $this->_connection;
}
public function is_ready()
Check if system is ready.
public function is_ready()
{
! $this->_connection && $this->connect();
return (bool) $this->_connection;
}
public function pub($channel, $what)
Publish new event.
public function pub($channel, $what)
{
! $this->_connection && $this->connect();
return $this->_connection->pub($channel, $what);
}
public function sub($channels, $callback)
Subscribe for one or more events.
public function sub($channels, $callback)
{
! $this->_connection && $this->connect();
return $this->_connection->sub($channels, $callback);
}
_ hooks and helpers; not routable as page actionspublic function __call($name, $args)
Catch missing method call.
public function __call($name, $args)
{
! $this->_connection && $this->connect();
// Support for driver-specific methods
if (is_object($this->_connection) && method_exists($this->_connection, $name)) {
return call_user_func_array([$this->_connection, $name], $args);
}
return main()->extend_call($this, $name, $args);
}