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.

HttpConfigFetch.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* global $, config, interfaceConfig */
  2. const logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var configUtil = require('./Util');
  4. var HttpConfig = {
  5. /**
  6. * Sends HTTP POST request to specified <tt>endpoint</tt>. In request
  7. * the name of the room is included in JSON format:
  8. * {
  9. * "rooomName": "someroom12345"
  10. * }
  11. * @param endpoint the name of HTTP endpoint to which HTTP POST request will
  12. * be sent.
  13. * @param roomName the name of the conference room for which config will be
  14. * requested.
  15. * @param complete
  16. */
  17. obtainConfig: function (endpoint, roomName, complete) {
  18. logger.info(
  19. "Send config request to " + endpoint + " for room: " + roomName);
  20. $.ajax(
  21. endpoint,
  22. {
  23. method: 'POST',
  24. contentType: 'application/json',
  25. data: JSON.stringify({"roomName": roomName}),
  26. dataType: 'json',
  27. error: function(jqXHR, textStatus, errorThrown) {
  28. logger.error("Get config error: ", jqXHR, errorThrown);
  29. var error = "Get config response status: " + textStatus;
  30. complete(false, error);
  31. },
  32. success: function(data) {
  33. try {
  34. configUtil.overrideConfigJSON(
  35. config, interfaceConfig, data);
  36. complete(true);
  37. return;
  38. } catch (exception) {
  39. logger.error("Parse config error: ", exception);
  40. complete(false, exception);
  41. }
  42. }
  43. }
  44. );
  45. }
  46. };
  47. module.exports = HttpConfig;