git repos / oastat

commit 706263c0

sago007 · 2010-12-21 19:37
706263c0ee2c4592613d5668a9a0f7054b553f9b patch · browse files
parent 4d4dc146189ae7bfeba22fc28b41f427402acb78

Make all sql commands in one go to reduce the risk of disconnects


git-svn-id: http://oastat.googlecode.com/svn/trunk@9 a36be8df-c75f-1e49-46ad-4f0ee64bdc62

Changed files

M src/oastat.cpp before
diff --git a/src/oastat.cpp b/src/oastat.cpp index 8faf472..20f1917 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp
@@ -19,12 +19,13 @@ Copyright (C) 2010 Poul Sander (oastat@poulsander.com)
===========================================================================
*/
-#define VERSION "0.1 BETA"
+#define VERSION "0.2 BETA"
#include <iostream>
#include <vector>
#include <gcrypt.h>
#include <stdio.h>
+#include <list>
using namespace std;
@@ -149,21 +150,34 @@ int main (int argc, const char* argv[])
static int processStdIn() {
string line;
OaStatStruct oss;
+ list<OaStatStruct> osslist;
bool done = true;
try{
- while( getline(cin,line) ) {
- oss.clear();
- oss.parseLine(line);
- for(int i=0;i<commands.size();i++) {
- try {
- commands.at(i)->process(oss);
- } catch (exception &e) {
- cerr << "oastat: Sql_error at line: \"" << line << "\"" << endl <<
- "oastat: Error is: " << e.what() <<
- "oastat: Last error will be ignored" << endl;
+ while( getline(cin,line) )
+ {
+ oss.clear();
+ oss.parseLine(line);
+ osslist.push_back(oss);
+ if(oss.command=="ShutdownGame")
+ {
+ while(!osslist.empty())
+ {
+ oss = osslist.front();
+ osslist.pop_front();
+ for(int i=0;i<commands.size();i++)
+ {
+ try {
+ commands.at(i)->process(oss);
+ } catch (exception &e)
+ {
+ cerr << "oastat: Sql_error at line: \"" << line << "\"" << endl <<
+ "oastat: Error is: " << e.what() <<
+ "oastat: Last error will be ignored" << endl;
+ }
+ }
+ }
}
}
- }
} catch (exception &e2) {
/*
If there is an error write it in the log and try again continue