src/sb/XMPP/Client.php
public function login()
    {

        //connect if not connected
        if(!$this->connected){

            $this->reconnect();
        }
        //calc the jid from uname+host
        $this->jid = $this->uname.'@'.substr($this->host, strpos($this->host, '//')+2);

        if($this->pass){

            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->uname . "\x00" . $this->pass) . "</auth>");
        } else {
            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />");
    }

        $buffer = $this->read();
        if(substr($buffer, 0, 5) == '<fail'){
            $this->onError(0, 'Cound not log in');
            return false;

        }

        $this->client_name = empty($this->client_name) ? __CLASS__ : $this->client_name;

        if(!$this->sendClientName()){
            return false;
        }

        $this->setStatus($this->status);

        $this->onAfterLogin();

        return true;

    }
public function login()
    {

        //connect if not connected
        if(!$this->connected){

            $this->reconnect();
        }
        //calc the jid from uname+host
        $this->jid = $this->uname.'@'.substr($this->host, strpos($this->host, '//')+2);

        if($this->pass){

            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode("\x00" . $this->uname . "\x00" . $this->pass) . "</auth>");
        } else {
            $this->write("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />");
    }

        $buffer = $this->read();
        if(substr($buffer, 0, 5) == '<fail'){
            $this->onError(0, 'Cound not log in');
            return false;

        }

        $this->client_name = empty($this->client_name) ? __CLASS__ : $this->client_name;

        if(!$this->sendClientName()){
            return false;
        }

        $this->setStatus($this->status);

        $this->onAfterLogin();

        return true;

    }
public function login ( ) { //connect if not connected if ( ! $ this -> connected ) { $ this -> reconnect ( ) ; } //calc the jid from uname+host $ this -> jid = $ this -> uname . '@' . substr ( $ this -> host , strpos ( $ this -> host , '//' ) + 2 ) ; if ( $ this -> pass ) { $ this -> write ( "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>" . base64_encode ( "\x00" . $ this -> uname . "\x00" . $ this -> pass ) . "</auth>" ) ; } else { $ this -> write ( "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='ANONYMOUS' />" ) ; } $ buffer = $ this -> read ( ) ; if ( substr ( $ buffer , 0 , 5 ) == '<fail' ) { $ this -> onError ( 0 , 'Cound not log in' ) ; return false ; } $ this -> client_name = empty ( $ this -> client_name ) ? __CLASS__ : $ this -> client_name ; if ( ! $ this -> sendClientName ( ) ) { return false ; } $ this -> setStatus ( $ this -> status ) ; $ this -> onAfterLogin ( ) ; return true ; }
Login to the XMPP server as a user and set their precence to avaiable
@return boolean
Login to the XMPP server as a user and set their precence to avaiable