Created
April 5, 2011 13:40
-
-
Save chucre/903612 to your computer and use it in GitHub Desktop.
xmpp plugin for phonegap use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onMessage = function() { | |
var options = { | |
to:'outrousuario@jabber.org', | |
subject:'teste', | |
body:'teste' | |
} | |
window.plugins.xmpp.send( | |
options, | |
function(success) { | |
alert("send success") | |
}, function(fail) { | |
alert("send failed"); | |
}); | |
window.plugins.xmpp.onMessage( | |
function(success) { | |
alert("mensage inbound: "+JSON.stringify(success)); | |
}, function(fail) { | |
alert("onMessage failed: " + fail); | |
}); | |
} | |
login = function() { | |
var options = { | |
user:'usuario', | |
password:'senha' | |
} | |
var result = window.plugins.xmpp.login( | |
options, | |
function(success) { | |
alert("login success: " + success); | |
onMessage(); | |
}, function(fail) { | |
alert("login failed: " + fail); | |
}); | |
} | |
connect = function(){ | |
var options = { | |
host:'jabber.org', | |
host:'jabber.org', | |
port:5222 | |
} | |
var result = window.plugins.xmpp.connect( | |
options, | |
function(success) { | |
alert("connect success: " + success); | |
login(); | |
}, function(fail) { | |
alert("connect failed: " + fail); | |
}); | |
} | |
document.addEventListener("deviceready", connect, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment