您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

HttpConfigFetch.js 1.7KB

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