XMPPStream::wait_for_stream_features PHP Method

wait_for_stream_features() public method

XEP-0170: Recommended Order of Stream Feature Negotiation
public wait_for_stream_features ( $event, $args )
    public function wait_for_stream_features($event, $args)
    {
        switch ($event) {
            case "stanza_cb":
                $stanza = $args[0];
                // get starttls requirements
                $starttls = $stanza->exists('starttls', XMPP::NS_TLS);
                if ($starttls) {
                    if ($this->force_tls) {
                        $required = true;
                    } else {
                        $required = $starttls->exists('required') ? true : false;
                    }
                } else {
                    $required = false;
                }
                if ($starttls && $required) {
                    $this->send_starttls_pkt();
                    return "wait_for_tls_result";
                }
                // handle auth mech
                $mechs = $stanza->exists('mechanisms', XMPP::NS_SASL);
                if ($mechs) {
                    $new_state = $this->handle_auth_mechs($stanza, $mechs);
                    return $new_state ? $new_state : "wait_for_sasl_response";
                }
                // post auth
                $bind = $stanza->exists('bind', XMPP::NS_BIND) ? true : false;
                $sess = $stanza->exists('session', XMPP::NS_SESSION) ? true : false;
                $comp = $stanza->exists('compression', XMPP::NS_COMPRESSION_FEATURE) ? true : false;
                if ($bind) {
                    $this->send_bind_pkt($this->resource);
                    return "wait_for_bind_response";
                    /*} elseif ($comp) {
                    				    // compression not supported due to bug in php stream filters
                    
                    					$this->send_compress_pkt("zlib");
                    					return "wait_for_compression_result";
                    				*/
                } else {
                    JAXLLogger::debug("no catch");
                }
                break;
            default:
                JAXLLogger::debug("uncatched {$event}");
                return $this->handle_other($event, $args);
                //return array("wait_for_stream_features", 0);
                break;
        }
    }