Added json_*.js output for pure JSON-only format.
This commit is contained in:
parent
0d24dfb3a9
commit
fbb3032fe4
1 changed files with 14 additions and 5 deletions
|
@ -29,6 +29,7 @@ namespace Mist {
|
||||||
capa["url_match"].append("/$.html");
|
capa["url_match"].append("/$.html");
|
||||||
capa["url_match"].append("/$.ico");
|
capa["url_match"].append("/$.ico");
|
||||||
capa["url_match"].append("/info_$.js");
|
capa["url_match"].append("/info_$.js");
|
||||||
|
capa["url_match"].append("/json_$.js");
|
||||||
capa["url_match"].append("/embed_$.js");
|
capa["url_match"].append("/embed_$.js");
|
||||||
cfg->addConnectorOptions(8080, capa);
|
cfg->addConnectorOptions(8080, capa);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,7 @@ namespace Mist {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((H.url.length() > 9 && H.url.substr(0, 6) == "/info_" && H.url.substr(H.url.length() - 3, 3) == ".js") || (H.url.length() > 10 && H.url.substr(0, 7) == "/embed_" && H.url.substr(H.url.length() - 3, 3) == ".js")){
|
if ((H.url.length() > 9 && H.url.substr(0, 6) == "/info_" && H.url.substr(H.url.length() - 3, 3) == ".js") || (H.url.length() > 10 && H.url.substr(0, 7) == "/embed_" && H.url.substr(H.url.length() - 3, 3) == ".js") || (H.url.length() > 9 && H.url.substr(0, 6) == "/json_" && H.url.substr(H.url.length() - 3, 3) == ".js")){
|
||||||
std::string response;
|
std::string response;
|
||||||
std::string rURL = H.url;
|
std::string rURL = H.url;
|
||||||
std::string host = H.GetHeader("Host");
|
std::string host = H.GetHeader("Host");
|
||||||
|
@ -225,7 +226,11 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
H.Clean();
|
H.Clean();
|
||||||
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
H.SetHeader("Server", "mistserver/" PACKAGE_VERSION);
|
||||||
H.SetHeader("Content-Type", "application/javascript");
|
if (rURL.substr(0, 6) != "/json_"){
|
||||||
|
H.SetHeader("Content-Type", "application/javascript");
|
||||||
|
}else{
|
||||||
|
H.SetHeader("Content-Type", "application/json");
|
||||||
|
}
|
||||||
response = "// Generating info code for stream " + streamName + "\n\nif (!mistvideo){var mistvideo = {};}\n";
|
response = "// Generating info code for stream " + streamName + "\n\nif (!mistvideo){var mistvideo = {};}\n";
|
||||||
JSON::Value json_resp;
|
JSON::Value json_resp;
|
||||||
IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||||
|
@ -336,9 +341,13 @@ namespace Mist {
|
||||||
|
|
||||||
configLock.post();
|
configLock.post();
|
||||||
configLock.close();
|
configLock.close();
|
||||||
#include "../embed.js.h"
|
if (rURL.substr(0, 6) != "/json_"){
|
||||||
response += "mistvideo['" + streamName + "'] = " + json_resp.toString() + ";\n";
|
response += "mistvideo['" + streamName + "'] = " + json_resp.toString() + ";\n";
|
||||||
if (rURL.substr(0, 6) != "/info_" && !json_resp.isMember("error")){
|
}else{
|
||||||
|
response = json_resp.toString();
|
||||||
|
}
|
||||||
|
if (rURL.substr(0, 7) == "/embed_" && !json_resp.isMember("error")){
|
||||||
|
#include "../embed.js.h"
|
||||||
response.append("\n(");
|
response.append("\n(");
|
||||||
if (embed_js[embed_js_len - 2] == ';'){//check if we have a trailing ;\n or just \n
|
if (embed_js[embed_js_len - 2] == ';'){//check if we have a trailing ;\n or just \n
|
||||||
response.append((char*)embed_js, (size_t)embed_js_len - 2); //remove trailing ";\n" from xxd conversion
|
response.append((char*)embed_js, (size_t)embed_js_len - 2); //remove trailing ";\n" from xxd conversion
|
||||||
|
|
Loading…
Add table
Reference in a new issue