You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

do_external_connect.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* global config, getRoomName, getConfigParamsFromUrl */
  2. /* global createConnectionExternally */
  3. /**
  4. * Implements extrnal connect using createConnectionExtenally function defined
  5. * in external_connect.js for Jitsi Meet. Parses the room name and token from
  6. * the url and executes createConnectionExtenally.
  7. *
  8. * NOTE: If you are using lib-jitsi-meet without Jitsi Meet you should use this
  9. * file as reference only because the implementation is Jitsi Meet specific.
  10. *
  11. * NOTE: For optimal results this file should be included right after
  12. * exrnal_connect.js.
  13. */
  14. /**
  15. * Executes createConnectionExternally function.
  16. */
  17. (function () {
  18. var params = getConfigParamsFromUrl();
  19. //Url params have higher proirity than config params
  20. var url = config.externalConnectUrl;
  21. if(params.hasOwnProperty('config.externalConnectUrl'))
  22. url = params["config.externalConnectUrl"];
  23. /**
  24. * Check if connect from connection.js was executed and executes the handler
  25. * that is going to finish the connect work.
  26. */
  27. function checkForConnectHandlerAndConnect() {
  28. if(window.APP && window.APP.connect.status === "ready") {
  29. window.APP.connect.handler();
  30. }
  31. }
  32. function error_callback(error){
  33. if(error) //error=undefined if external connect is disabled.
  34. console.warn(error);
  35. // Sets that global variable to be used later by connect method in
  36. // connection.js
  37. window.XMPPAttachInfo = {
  38. status: "error"
  39. };
  40. checkForConnectHandlerAndConnect();
  41. }
  42. if(!url || !window.createConnectionExternally) {
  43. error_callback();
  44. return;
  45. }
  46. var room_name = getRoomName();
  47. if(!room_name) {
  48. error_callback();
  49. return;
  50. }
  51. url += "?room=" + room_name;
  52. var token = params["config.token"] || config.token;
  53. if(token)
  54. url += "&token=" + token;
  55. createConnectionExternally(url, function(connectionInfo) {
  56. // Sets that global variable to be used later by connect method in
  57. // connection.js
  58. window.XMPPAttachInfo = {
  59. status: "success",
  60. data: connectionInfo
  61. };
  62. checkForConnectHandlerAndConnect();
  63. }, error_callback);
  64. })();