Merge pull request #349 from mksh/master
Some fixes in dynamic config retrieval
This commit is contained in:
commit
aebfa33383
|
@ -19,14 +19,21 @@ var HttpConfig = {
|
|||
console.info(
|
||||
"Send config request to " + endpoint + " for room: " + roomName);
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
var error = null;
|
||||
request.onreadystatechange = function (aEvt) {
|
||||
if (request.readyState == 4) {
|
||||
var status = request.status;
|
||||
if (status === 200) {
|
||||
|
||||
$.ajax(
|
||||
endpoint,
|
||||
{
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify({"roomName": roomName}),
|
||||
dataType: 'json',
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
console.error("Get config error: ", jqXHR, errorThrown)
|
||||
error = "Get config response status: " + textStatus;
|
||||
complete(false, error);
|
||||
},
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
try {
|
||||
var data = JSON.parse(request.responseText);
|
||||
configUtil.overrideConfigJSON(
|
||||
config, interfaceConfig, data);
|
||||
complete(true);
|
||||
|
@ -34,21 +41,11 @@ var HttpConfig = {
|
|||
} catch (exception) {
|
||||
console.error("Parse config error: ", exception);
|
||||
error = exception;
|
||||
}
|
||||
} else {
|
||||
console.error("Get config error: ", request, status);
|
||||
error = "Get config response status: " + status;
|
||||
}
|
||||
complete(false, error);
|
||||
}
|
||||
};
|
||||
|
||||
request.open("POST", endpoint, true);
|
||||
|
||||
request.setRequestHeader(
|
||||
"Content-Type", "application/json;charset=UTF-8");
|
||||
|
||||
request.send({ "roomName": roomName });
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue