Added RECORDING_END trigger

This commit is contained in:
Thulinma 2016-12-15 16:48:19 +01:00
parent 2752d5bd07
commit 0c673364d2
2 changed files with 14 additions and 2 deletions

View file

@ -61,6 +61,7 @@ namespace Mist{
DEBUG_MSG(DLVL_WARN, "Warning: MistOut created with closed socket!"); DEBUG_MSG(DLVL_WARN, "Warning: MistOut created with closed socket!");
} }
sentHeader = false; sentHeader = false;
isRecordingToFile = false;
} }
void Output::listener(Util::Config & conf, int (*callback)(Socket::Connection & S)){ void Output::listener(Util::Config & conf, int (*callback)(Socket::Connection & S)){
@ -912,8 +913,17 @@ namespace Mist{
/*LTS-START*/ /*LTS-START*/
if(Triggers::shouldTrigger("CONN_CLOSE", streamName)){ if(Triggers::shouldTrigger("CONN_CLOSE", streamName)){
std::string payload = streamName+"\n"+getConnectedHost()+"\n"+capa["name"].asStringRef()+"\n"+reqUrl; ///\todo generate payload std::string payload = streamName+"\n"+getConnectedHost()+"\n"+capa["name"].asStringRef()+"\n"+reqUrl;
Triggers::doTrigger("CONN_CLOSE", payload, streamName); //no stream specified Triggers::doTrigger("CONN_CLOSE", payload, streamName);
}
if (isRecordingToFile && config->hasOption("target") && Triggers::shouldTrigger("RECORDING_END", streamName)){
std::stringstream payl;
payl << streamName << '\n';
payl << config->getString("target") << '\n';
payl << capa["name"].asStringRef() << '\n';
payl << myConn.dataUp() << '\n';
payl << (Util::epoch() - myConn.connTime()) << '\n';
Triggers::doTrigger("RECORDING_END", payl.str(), streamName);
} }
/*LTS-END*/ /*LTS-END*/
@ -1276,6 +1286,7 @@ namespace Mist{
return false; return false;
} }
close(outFile); close(outFile);
isRecordingToFile = true;
return true; return true;
} }

View file

@ -93,6 +93,7 @@ namespace Mist {
void loadPageForKey(long unsigned int trackId, long long int keyNum); void loadPageForKey(long unsigned int trackId, long long int keyNum);
int pageNumForKey(long unsigned int trackId, long long int keyNum); int pageNumForKey(long unsigned int trackId, long long int keyNum);
int pageNumMax(long unsigned int trackId); int pageNumMax(long unsigned int trackId);
bool isRecordingToFile;
unsigned int lastStats;///<Time of last sending of stats. unsigned int lastStats;///<Time of last sending of stats.
long long unsigned int firstTime;///< Time of first packet after last seek. Used for real-time sending. long long unsigned int firstTime;///< Time of first packet after last seek. Used for real-time sending.
std::map<unsigned long, unsigned long> nxtKeyNum;///< Contains the number of the next key, for page seeking purposes. std::map<unsigned long, unsigned long> nxtKeyNum;///< Contains the number of the next key, for page seeking purposes.