Dear Metajack,
i try to use the strophe register plugin and i'm facing issues... i commented the lines in the plugin as suggested here:
http://stackoverflow.com/questions/1...openfire-usage
...now this is my code for triggering the connect:
function connect() {
$(document).trigger('connect', {
jid : "register@maschine",
password : "register"
});
}
...and this is the handler method:
$(document).bind('connect', function (ev, data) {
var conn = new Strophe.Connection(MyConnection.url);
var callback = function (status) {
if (status === Strophe.Status.CONNECTED) {
console.log("logged in!");
$(document).trigger('connected');
} else if (status === Strophe.Status.REGISTER) {
console.log("in status register...");
conn.register.fields.username = "register";
conn.register.fields.password = "register";
conn.register.submit();
} else if (status === Strophe.Status.REGISTERED) {
console.log("registered!");
conn.register.authenticate();
}
};
conn.register.connect("maschine", callback, 60, 1);
MyConnection.connection = conn;
});
...this works fine first time...the second time i start the app it tries to register again...why is strophe status "connected" never reached when i start the app again after the successful registration of the account? I did a console.log in the submit-method of the plugin and every time i start the app second time it seems to hang in this method...maybe you can tell me whats wrong with my code?
Before i used the plugin my code looked like this in the handler:
conn.connect(data.jid, data.password, function (status) {
if (status === Strophe.Status.CONNECTED) {
$(document).trigger('connected');
} else if (status === Strophe.Status.DISCONNECTED) {
connect();
}
else if (status === Strophe.Status.ERROR) {
alert ('error);
} else if (status === Strophe.Status.CONNECTING) {
alert ('connecting');
} else if (status === Strophe.Status.CONNFAIL) {
alert ('connfail');
} else if (status === Strophe.Status.AUTHENTICATING) {
alert ('authenticating');
} else if (status === Strophe.Status.AUTHFAIL) {
alert('authfail');
} else if (status === Strophe.Status.ATTACHED) {
alert ('attached');
} else {
alert("error" + status);
}
});
...if i use this code, where do i have to put the code for the registration, so that registration only happens if needed and otherwise a normal login happens? I'm not a javascript expert so it would be nice if you perhaps could show me the code for this problem. I would be very thankful... Please tell me if you need more information...
greetz