#include <exception>
+#include <msp/core/maputils.h>
#include <msp/core/refptr.h>
#include <msp/net/inet.h>
#include <msp/net/resolve.h>
try
{
cl.response = response.get();
+ responses[cl.response] = &cl;
signal_request.emit(*cl.request, *response);
if(cl.async)
response.release();
else
{
+ responses.erase(cl.response);
cl.response = 0;
if(response->get_status()==NONE)
{
}
catch(const exception &e)
{
+ responses.erase(cl.response);
cl.response = 0;
response = new Response(INTERNAL_ERROR);
response->add_content(e.what());
Server::Client &Server::get_client_by_response(Response &resp)
{
- for(list<Client>::iterator i=clients.begin(); i!=clients.end(); ++i)
- if(i->response==&resp)
- return *i;
-
- // XXX Do this differently
- throw invalid_argument("Response does not belong to any client");
+ return *get_item(responses, &resp);
}
Net::StreamServerSocket sock;
std::list<Client> clients;
+ std::map<Response *, Client *> responses;
IO::EventDispatcher *event_disp;
public: