Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

do_external_connect.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. var url = params["config.externalConnectUrl"] || config.externalConnectUrl;
  20. /**
  21. * Check if connect from connection.js was executed and executes the handler
  22. * that is going to finish the connect work.
  23. */
  24. function checkForConnectHandlerAndConnect() {
  25. if(window.APP && window.APP.connect.status === "ready") {
  26. window.APP.connect.handler();
  27. }
  28. }
  29. function error_callback(error){
  30. if(error) //error=undefined if external connect is disabled.
  31. console.warn(error);
  32. // Sets that global variable to be used later by connect method in
  33. // connection.js
  34. window.XMPPAttachInfo = {
  35. status: "error"
  36. };
  37. checkForConnectHandlerAndConnect();
  38. }
  39. if(!url || !window.createConnectionExternally) {
  40. error_callback();
  41. return;
  42. }
  43. var room_name = getRoomName();
  44. if(!room_name) {
  45. error_callback();
  46. return;
  47. }
  48. url += "?room=" + room_name;
  49. var token = params["config.token"] || config.token;
  50. if(token)
  51. url += "&token=" + token;
  52. createConnectionExternally(url, function(connectionInfo) {
  53. // Sets that global variable to be used later by connect method in
  54. // connection.js
  55. window.XMPPAttachInfo = {
  56. status: "success",
  57. data: connectionInfo
  58. };
  59. checkForConnectHandlerAndConnect();
  60. }, error_callback);
  61. })();