require_xep() public method

public require_xep ( array $xeps )
$xeps array
Example #1
0
 /**
  * Configures the XMPP Client
  */
 private function configure()
 {
     /**
      * It's actually really important that this class does not get defined in the __construct() function
      * because it sets it's own signal handlers, and will take over ours leading to zombie processes after
      * the parent gets killed.
      *
      * This needs to be instansiated AFTER this has forked into it's own process.
      */
     $config = $this->getContainer()->get('config');
     $this->client = new \JAXL(['jid' => $config['xmpp']['account']['jid'], 'pass' => $config['xmpp']['account']['password'], 'host' => $config['xmpp']['server']['host'], 'port' => $config['xmpp']['server']['port'], 'resource' => 'bot' . md5(time()), 'priv_dir' => sys_get_temp_dir() . '/.jaxl', 'force_tls' => $config['xmpp']['server']['ssl']['force_tls'], 'log_level' => JAXL_INFO, 'auth_type' => $config['xmpp']['server']['auth_type'], 'strict' => true, 'stream_context' => stream_context_create(['ssl' => ['verify_peer' => $config['xmpp']['server']['ssl']['verify_peer'], 'allow_self_signed' => $config['xmpp']['server']['ssl']['allow_self_signed'], 'verify_peer_name' => $config['xmpp']['server']['ssl']['verify_peer_name']]])]);
     $this->client->require_xep(['0045', '0203', '0199']);
 }
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
if ($argc < 5) {
    echo "Usage: {$argv['0']} jid pass room@service.domain.tld nickname\n";
    exit;
}
//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'log_level' => JAXL_INFO));
$client->require_xep(array('0045', '0203'));
//
// add necessary event callbacks here
//
$_room_full_jid = $argv[3] . "/" . $argv[4];
$room_full_jid = new XMPPJid($_room_full_jid);
$client->add_cb('on_auth_success', function () {
    global $client, $room_full_jid;
    _info("got on_auth_success cb, jid " . $client->full_jid->to_string());
    // join muc room
    $client->xeps['0045']->join_room($room_full_jid);
});
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    $client->send_end_stream();
    _info("got on_auth_failure cb with reason {$reason}");
                            $response = json_encode(array('Action' => 'IncomingCallEvent', 'Success' => 'True', 'From' => $from_caller_id, 'FromJid' => $from_jid, 'FromExt' => $from, 'Channel' => $event->getDestination()));
                            sendMessage($jid, $response);
                        }
                    }
                }
            } catch (Exception $e) {
                echo "Excepition in DialEvent: {$e}\n";
            }
        }
    }
});
// register_tick_function(array($pamiClient, 'process'));
$db = new Database();
$astdb = new AsteriskDB();
$xmpp_client = new JAXL(array('jid' => 'pbx', 'pass' => '123456', 'host' => 'avanpbx:5222'));
$xmpp_client->require_xep(array('0199'));
$connected = true;
$xmpp_client->add_cb('on_auth_failure', function ($reason) {
    global $xmpp_client;
    $xmpp_client->send_end_stream();
    _info("CALLBACK! got on_auth_failure cb with reason {$reason}");
});
$xmpp_client->add_cb('on_connect_error', function ($reason) {
    _info("connect error {$reason}");
});
$xmpp_client->add_cb('on_auth_success', function () {
    _info("connected!!");
    global $xmpp_client;
    $xmpp_client->set_status("available!", "dnd", 10);
});
$xmpp_client->add_cb('on_disconnect', function () {
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
if ($argc != 5) {
    echo "Usage: {$argv['0']} jid pass host port\n";
    exit;
}
//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$comp = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'host' => @$argv[3], 'port' => $argv[4], 'log_level' => JAXL_INFO));
//
// XEP's required (required)
//
$comp->require_xep(array('0114'));
//
// add necessary event callbacks here
//
$comp->add_cb('on_auth_success', function () {
    _info("got on_auth_success cb");
});
$comp->add_cb('on_auth_failure', function ($reason) {
    global $comp;
    $comp->send_end_stream();
    _info("got on_auth_failure cb with reason {$reason}");
});
$comp->add_cb('on_chat_message', function ($stanza) {
    global $comp;
    // echo back incoming message stanza
    $stanza->to = $stanza->from;
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
if ($argc < 3) {
    echo "Usage: {$argv['0']} jid pass\n";
    exit;
}
//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array('jid' => $argv[1], 'pass' => $argv[2], 'log_level' => JAXL_INFO));
$client->require_xep(array('0060'));
//
// add necessary event callbacks here
//
$client->add_cb('on_auth_success', function () {
    global $client;
    _info("got on_auth_success cb, jid " . $client->full_jid->to_string());
    // create node
    //$client->xeps['0060']->create_node('pubsub.localhost', 'dummy_node');
    // subscribe
    $client->xeps['0060']->subscribe('pubsub.localhost', 'dummy_node');
});
$client->add_cb('on_auth_failure', function ($reason) {
    global $client;
    $client->send_end_stream();
    _info("got on_auth_failure cb with reason {$reason}");
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 */
if ($argc < 2) {
    echo "Usage: {$argv['0']} domain\n";
    exit;
}
//
// initialize JAXL object with initial config
//
require_once 'jaxl.php';
$client = new JAXL(array('jid' => $argv[1], 'log_level' => JAXL_DEBUG));
$client->require_xep(array('0077'));
//
// below are two states which become part of
// our client's xmpp_stream lifecycle
// consider as if these methods are directly
// inside xmpp_stream state machine
//
// Note: $stanza = $args[0] is an instance of
// JAXLXml in xmpp_stream state methods,
// it is yet not ready for easy access
// patterns available on XMPPStanza instances
//
$form = array();
function wait_for_register_response($event, $args)
{
    global $client, $form;