diff options
author | deva <deva> | 2008-06-09 06:49:58 +0000 |
---|---|---|
committer | deva <deva> | 2008-06-09 06:49:58 +0000 |
commit | e80ccdfac750fdd318eecb35b5f48a3d251ec7ec (patch) | |
tree | c296fb042d17f75aad06ff95e5f48dcb8143dabd /server/src/server.cc | |
parent | c3a7893d9f2c67614257bc0dbfa802b9cc9ff056 (diff) |
Made output accumulation in a buffer and write in the end, thus enabling the corretc outputting of the error box if neccessary.
Diffstat (limited to 'server/src/server.cc')
-rw-r--r-- | server/src/server.cc | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/server/src/server.cc b/server/src/server.cc index 9708f9f..2ea782d 100644 --- a/server/src/server.cc +++ b/server/src/server.cc @@ -115,6 +115,8 @@ static void connection(TCPSocket &socket) while(i != transaction.requests.end()) { Request &request = *i; + std::string answer; + MacroParser mp(request.macro); mp.parse(); Macro *m = mp.getMacro(); @@ -156,51 +158,47 @@ static void connection(TCPSocket &socket) // Map the results LUAQueryMapper lqm(qp.result); - socket.write(" <course name=\""); - socket.write(templ->course.attributes["name"]); - socket.write("\">\n"); + answer += " <course name=\""; + answer += templ->course.attributes["name"]; + answer += "\">\n"; // Generate the macro and return it to the client std::vector< Macro >::iterator mi2 = templ->course.macroes.begin(); while(mi2 != templ->course.macroes.end()) { Macro ¯o = (*mi2); - socket.write(" <macro name=\""); - socket.write(macro.attributes["name"]); - socket.write("\">\n"); + answer += " <macro name=\"" + macro.attributes["name"] + "\">\n"; if(macro.attributes["name"] == request.macro) { // Handle lua programs if(m->luaprograms.size()) { - socket.write(" <luaprograms>\n"); + answer += " <luaprograms>\n"; std::vector< LUAProgram >::iterator lpi = m->luaprograms.begin(); while(lpi != m->luaprograms.end()) { - socket.write(" <luaprogram name=\""); - socket.write(lpi->attributes["name"]); - socket.write("\">\n"); + answer += " <luaprogram name=\"" + lpi->attributes["name"] + "\">\n"; - socket.write(lpi->attributes["lua"]); + answer += lpi->attributes["lua"]; - socket.write("\n </luaprogram>\n"); + answer += "\n </luaprogram>\n"; lpi++; } - socket.write(" </luaprograms>\n"); + answer += " </luaprograms>\n"; } - widgetgenerator(socket, *m, lqm, db); + answer += widgetgenerator(*m, lqm, db); } - socket.write(" </macro>\n"); + answer += " </macro>\n"; mi2++; } - socket.write(" </course>\n"); - + answer += " </course>\n"; + socket.write(answer); i++; } } catch(std::exception &e) { |