You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To register a JID you need to listen for REGISTER und REGISTERED in
your connection callback and use connection.register.connect() instead
of connection.connect().
On REGISTER you need to inspect the connection.register.fields
object, fill in every field and call connection.register.submit().
(There may be more fields than username and password!)
On REGISTERED you can can then call connection.authenticate() if you
want to login normally with the account you just created.
You should also listen for CONFLICT, REGIFAIL and NOTACCEPTABLE to catch
failure-status of registrations.
Example for registering a new account and logging in with it:
varcallback=function(status){if(status===Strophe.Status.REGISTER){// fill out the fieldsconnection.register.fields.username="juliet";connection.register.fields.password="R0m30";// calling submit will continue the registration processconnection.register.submit();}elseif(status===Strophe.Status.REGISTERED){console.log("registered!");// calling login will authenticate the registered JID.connection.authenticate();}elseif(status===Strophe.Status.CONFLICT){console.log("Contact already existed!");}elseif(status===Strophe.Status.NOTACCEPTABLE){console.log("Registration form not properly filled out.")}elseif(status===Strophe.Status.REGIFAIL){console.log("The Server does not support In-Band Registration")}elseif(status===Strophe.Status.CONNECTED){// do something after successful authentication}else{// Do other stuff}};connection.register.connect("example.com",callback,wait,hold);