JAXL::handle_presence PHP Method

handle_presence() public method

public handle_presence ( $stanza )
    public function handle_presence($stanza)
    {
        $stanza = new XMPPStanza($stanza);
        // if managing roster
        // catch available/unavailable type stanza
        if ($this->manage_roster) {
            $type = $stanza->type ? $stanza->type : "available";
            $jid = new XMPPJid($stanza->from);
            if ($type == 'available') {
                $this->roster[$jid->bare]->resources[$jid->resource] = $stanza;
            } elseif ($type == 'unavailable') {
                if (isset($this->roster[$jid->bare]) && isset($this->roster[$jid->bare]->resources[$jid->resource])) {
                    unset($this->roster[$jid->bare]->resources[$jid->resource]);
                }
            }
        }
        // if managing subscription requests
        // we need to automate stuff here
        if ($stanza->type == "subscribe" && $this->manage_subscribe != "none") {
            $this->subscribed($stanza->from);
            if ($this->manage_subscribe == "mutual") {
                $this->subscribe($stanza->from);
            }
        }
        $this->ev->emit('on_presence_stanza', array($stanza));
    }