comparison 3rdparty/vmime/examples/example6_tracer.hpp @ 0:a4671277546c tip

created the repository for the thymian project
author ferencd
date Tue, 17 Aug 2021 11:19:54 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:a4671277546c
1
2 /** Tracer used to demonstrate logging communication between client and server.
3 */
4
5 class myTracer : public vmime::net::tracer
6 {
7 public:
8
9 myTracer(vmime::shared_ptr <std::ostringstream> stream,
10 vmime::shared_ptr <vmime::net::service> serv, const int connectionId)
11 : m_stream(stream), m_service(serv), m_connectionId(connectionId)
12 {
13 }
14
15 void traceSend(const vmime::string& line)
16 {
17 *m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
18 << "] C: " << line << std::endl;
19 }
20
21 void traceReceive(const vmime::string& line)
22 {
23 *m_stream << "[" << m_service->getProtocolName() << ":" << m_connectionId
24 << "] S: " << line << std::endl;
25 }
26
27 private:
28
29 vmime::shared_ptr <std::ostringstream> m_stream;
30 vmime::shared_ptr <vmime::net::service> m_service;
31 const int m_connectionId;
32 };
33
34 class myTracerFactory : public vmime::net::tracerFactory
35 {
36 public:
37
38 myTracerFactory(vmime::shared_ptr <std::ostringstream> stream)
39 : m_stream(stream)
40 {
41 }
42
43 vmime::shared_ptr <vmime::net::tracer> create
44 (vmime::shared_ptr <vmime::net::service> serv, const int connectionId)
45 {
46 return vmime::make_shared <myTracer>(m_stream, serv, connectionId);
47 }
48
49 private:
50
51 vmime::shared_ptr <std::ostringstream> m_stream;
52 };
53