PHPDaemon\Clients\WebSocket\Example::connect PHP Method

connect() public method

public connect ( )
    public function connect()
    {
        $this->wsclient->getConnection($this->config->url->value, function ($conn) {
            $this->wsconn = $conn;
            if ($conn->connected) {
                $conn->sendFrame('foobar');
                $conn->on('disconnect', function ($conn) {
                    $this->log('Connection lost... Reconnect in ' . $this->config->reconnect->value . ' sec');
                    $this->connect();
                })->on('frame', function ($conn, $frame) {
                    $this->log('Got frame: ' . $frame);
                });
            } else {
                $this->log('Couldn\'t connect to ' . $this->config->url->value);
            }
        });
    }