Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAXL XMPP script works, but never stops loading #58

Open
lcyabcd opened this issue May 15, 2015 · 3 comments
Open

JAXL XMPP script works, but never stops loading #58

lcyabcd opened this issue May 15, 2015 · 3 comments

Comments

@lcyabcd
Copy link

lcyabcd commented May 15, 2015

I am implementing the Facebook Chat into my site so I used JAXL in order to implement the XMPP. It seems that the script posts the message that I wanted, but whenever I run it, the page just keeps loading and loading and never stops. In order to get back onto that site, I have to clear the cookies for it in my browser. Not sure what the problem could be, I am not seeing any errors in my log. Take a look at the code: Thanks!

$client = new JAXL(array(
'jid' => $user['facebookID']."@chat.facebook.com",
'fb_app_key' => "XXXX",
'fb_access_token' => $user['facebook_access_token'],
'force_tls' => true,
'auth_type' => 'X-FACEBOOK-PLATFORM',
'log_level' => JAXL_INFO,
'priv_dir' => "includes/lib/jaxl/tmp"
));

$client->add_cb('on_auth_success', function() {
    global $client;
    _info("got on_auth_success cb, jid ".$client->full_jid->to_string());
    $client->set_status("available!", "dnd", 10);

    $msg = new XMPPMsg(array('to'=>'[email protected]'), 'test message');
    $client->send($msg);
});

$client->add_cb('on_auth_failure', function($reason) {
    global $client;
    $client->send_end_stream();
    _info("got on_auth_failure cb with reason $reason");
});

$client->add_cb('on_chat_message', function($stanza) {
    global $client;

    // echo back incoming message stanza
    $stanza->to = $stanza->from;
    $stanza->from = $client->full_jid->to_string();
    $client->send($stanza);
});

$client->add_cb('on_disconnect', function() {
    _info("got on_disconnect cb");
});

//
// finally start configured xmpp stream
//
$client->start();
@calebtr
Copy link

calebtr commented May 15, 2015

Is this code in your page? The process running JAXL will keep running until you tell JAXL to stop. That's why the page appears to be loading and loading and loading.

If you want to have an XMPP client on a web page, you need to use a BOSH client - something like what is described at http://abhinavsingh.com/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/ - though I don't see all of the code I am expecting to see.

@abhinavsingh
Copy link
Member

@lcyabcd You probably want to close the client connection once it has sent out the message. Example, adding $client->send_end_stream() after $client->send($stanza) will terminate the client after it sends out the 1st message.

@lcyabcd
Copy link
Author

lcyabcd commented May 19, 2015

I want to have a web client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants