-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessageDbUp.cpp
34 lines (29 loc) · 961 Bytes
/
MessageDbUp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* MessageDbUp.cpp
*
* Created on: 1 gru 2014
* Author: edek437
*/
#include "MessageDbUp.h"
#include "boost/regex.hpp"
MessageDbUp::MessageDbUp(Poco::Net::StreamSocket& sock, std::string& in_message,
std::vector<MessageStruct> *in_vstr, Poco::RWLock *rwl) :
Handler(sock), message(in_message), vstr(in_vstr), mes_rwl(rwl) {
// TODO Auto-generated constructor stub
}
void MessageDbUp::handle() {
std::string regex =
"<receiver>(.*)</receiver><sender>(.*)</sender><message>(.*)</message>";
boost::regex exp(regex);
std::string rec = boost::regex_replace(message, exp, "\\1");
std::string send = boost::regex_replace(message, exp, "\\2");
std::string mes = boost::regex_replace(message, exp, "\\3");
mes_rwl->writeLock();
vstr->push_back(MessageStruct(rec, send, mes));
mes_rwl->unlock();
bool b = true;
get_socket().sendBytes((bool*) &b, sizeof(bool));
}
MessageDbUp::~MessageDbUp() {
// TODO Auto-generated destructor stub
}