forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogServer.h
More file actions
87 lines (66 loc) · 2.08 KB
/
DialogServer.h
File metadata and controls
87 lines (66 loc) · 2.08 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// DialogServer.h
//
// Definition of the DialogServer class.
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef DialogServer_INCLUDED
#define DialogServer_INCLUDED
#include "Poco/Net/Net.h"
#include "Poco/Net/ServerSocket.h"
#include "Poco/Net/StreamSocket.h"
#include "Poco/Thread.h"
#include "Poco/Event.h"
#include "Poco/Mutex.h"
#include <vector>
#include "Poco/Net/Session.h"
class DialogServer: public Poco::Runnable
/// A server for testing FTPClientSession and friends.
{
public:
DialogServer(bool acceptCommands = true, bool ssl = false);
/// Creates the DialogServer.
~DialogServer();
/// Destroys the DialogServer.
Poco::UInt16 port() const;
/// Returns the port the echo server is
/// listening on.
void run();
/// Does the work.
const std::string& lastCommand() const;
/// Returns the last command received by the server.
std::string popCommand();
/// Pops the next command from the list of received commands.
std::string popCommandWait();
/// Pops the next command from the list of received commands.
/// Waits until a command is available.
const std::vector<std::string>& lastCommands() const;
/// Returns the last command received by the server.
void addResponse(const std::string& response);
/// Sets the next response returned by the server.
void clearCommands();
/// Clears all commands.
void clearResponses();
/// Clears all responses.
void log(bool flag);
/// Enables or disables logging to stdout.
Poco::Net::Session::Ptr getSslSession();
void setSslSession(Poco::Net::Session::Ptr cSession);
private:
Poco::Net::ServerSocket _socket;
Poco::Thread _thread;
Poco::Event _ready;
mutable Poco::FastMutex _mutex;
bool _stop;
std::vector<std::string> _nextResponses;
std::vector<std::string> _lastCommands;
bool _acceptCommands;
bool _log;
bool _ssl;
Poco::Net::Session::Ptr _SSLsession = nullptr;
};
#endif // DialogServer_INCLUDED