Guest User

Untitled

a guest
May 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. var connection = null;
  2. var server_dominio = 'server';
  3. var BOSH_SERVICE = '/xmpp-httpbind';
  4.  
  5. $(document).ready(function () {
  6. connection = new Strophe.Connection(BOSH_SERVICE);
  7. $('#register').bind('click', function () {
  8.  
  9. var user = $("#username").val();
  10. var pass = $("#password").val();
  11.  
  12. connection.register.connect(server_dominio,function (status) {
  13. if (status === Strophe.Status.REGISTER) {
  14. connection.register.fields.username = user;
  15. connection.register.fields.password = pass;
  16. console.info("registering...",user," status ",status);
  17. connection.register.submit();
  18. }
  19. else if (status === Strophe.Status.REGISTERED) {
  20. alert("register");
  21. console.info("Registerd!",user," status ",status);
  22. //connection.disconnect();
  23. connection.authenticate();
  24. }
  25. else if (status === Strophe.Status.CONFLICT) {
  26. console.error("Username already exists.");
  27. }
  28. else if (status === Strophe.Status.NOTACCEPTABLE) {
  29. console.error("Registration form not properly filled out.");
  30. }
  31. else if (status === Strophe.Status.REGIFAIL) {
  32. console.log("The Server does not support In-Band Registration");
  33. }
  34. else if (status === Strophe.Status.CONNECTED) {
  35. console.info("Connected."," status ",status);
  36. }
  37. else if (status === Strophe.Status.DISCONNECTING) {
  38. console.log("Disconneting..."," status ",status);
  39. }
  40. else if (status === Strophe.Status.DISCONNECTED) {
  41. console.log("Disconneted."," status ",status);
  42. }
  43. else {
  44. }
  45. });
  46. });
  47. });
Add Comment
Please, Sign In to add comment