Implemented push setting storage.

This commit is contained in:
Thulinma 2016-05-11 15:08:22 +02:00
parent 4a3c2a055b
commit b9f6107528
3 changed files with 29 additions and 0 deletions

View file

@ -616,6 +616,10 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
Response["push_auto_list"] = Controller::Storage["autopushes"];
}
if (Request.isMember("push_settings")){
Controller::pushSettings(Request["push_settings"], Response["push_settings"]);
}
Controller::configChanged = true;
}else{//unauthorized

View file

@ -12,6 +12,9 @@ namespace Controller {
/// Internal list of currently active pushes
std::map<pid_t, JSON::Value> activePushes;
/// Internal list of waiting pushes
std::deque<JSON::Value> waitingPushes;
/// Immediately starts a push for the given stream to the given target.
/// Simply calls Util::startPush and stores the resulting PID in the local activePushes map.
void startPush(std::string & stream, std::string & target){
@ -30,6 +33,10 @@ namespace Controller {
Util::Procs::Stop(ID);
}
/// Loops, checking every second if any pushes need restarting.
void pushCheckLoop(){
}
/// Gives a list of all currently active pushes
void listPush(JSON::Value & output){
output.null();
@ -116,5 +123,18 @@ namespace Controller {
}
}
void pushSettings(const JSON::Value & request, JSON::Value & response){
if (request.isObject()){
if (request.isMember("wait")){
Controller::Storage["push_settings"]["wait"] = request["wait"].asInt();
}
if (request.isMember("maxspeed")){
Controller::Storage["push_settings"]["maxspeed"] = request["maxspeed"].asInt();
}
}
response = Controller::Storage["push_settings"];
}
}

View file

@ -14,6 +14,11 @@ namespace Controller {
void removePush(const JSON::Value & request);
void removePush(const std::string & streamname);
//internal use only
void doAutoPush(std::string & streamname);
void pushCheckLoop();
//for storing/retrieving settings
void pushSettings(const JSON::Value & request, JSON::Value & response);
}