PHPDaemon\Examples\ExampleJabberbot::connect PHP Метод

connect() публичный Метод

public connect ( )
    public function connect()
    {
        $app = $this;
        $this->xmppclient->getConnection($this->config->url->value, function ($conn) use($app) {
            $app->xmppconn = $conn;
            if ($conn->connected) {
                \PHPDaemon\Core\Daemon::log('Jabberbot connected at ' . $this->config->url->value);
                $conn->presence('I\'m a robot.', 'chat');
                $conn->bind('message', function ($conn, $msg) {
                    \PHPDaemon\Core\Daemon::log('JabberBot: got message \'' . $msg['body'] . '\'');
                    $conn->message($msg['from'], 'You just wrote: ' . $msg['body']);
                    // send the message back
                });
                $conn->bind('disconnect', function () use($app) {
                    $app->connect();
                });
            } else {
                \PHPDaemon\Core\Daemon::log('Jabberbot: unable to connect (' . $this->config->url->value . ')');
            }
        });
    }