From e80ccdfac750fdd318eecb35b5f48a3d251ec7ec Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 9 Jun 2008 06:49:58 +0000 Subject: Made output accumulation in a buffer and write in the end, thus enabling the corretc outputting of the error box if neccessary. --- server/src/server.cc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'server/src/server.cc') 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.attributes["name"]); - socket.write("\">\n"); + answer += " 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(" \n"); + answer += " \n"; if(macro.attributes["name"] == request.macro) { // Handle lua programs if(m->luaprograms.size()) { - socket.write(" \n"); + answer += " \n"; std::vector< LUAProgram >::iterator lpi = m->luaprograms.begin(); while(lpi != m->luaprograms.end()) { - socket.write(" attributes["name"]); - socket.write("\">\n"); + answer += " attributes["name"] + "\">\n"; - socket.write(lpi->attributes["lua"]); + answer += lpi->attributes["lua"]; - socket.write("\n \n"); + answer += "\n \n"; lpi++; } - socket.write(" \n"); + answer += " \n"; } - widgetgenerator(socket, *m, lqm, db); + answer += widgetgenerator(*m, lqm, db); } - socket.write(" \n"); + answer += " \n"; mi2++; } - socket.write(" \n"); - + answer += " \n"; + socket.write(answer); i++; } } catch(std::exception &e) { -- cgit v1.2.3