1
2
3
4
5
6 #ifndef CMAJOR_BUILD_CONNECTION_INCLUDED
7 #define CMAJOR_BUILD_CONNECTION_INCLUDED
8 #include <cmajor/build/Log.hpp>
9
10 namespace cmajor { namespace build {
11
12 class MessageBase;
13 class BuildServer;
14 class Host;
15
16 class Connection
17 {
18 public:
19 Connection(Log* log_);
20 virtual ~Connection();
21 void Send(JsonObject* messageObject);
22 virtual void DoSend(JsonObject* messageObject) = 0;
23 std::unique_ptr<MessageBase> Receive();
24 virtual std::unique_ptr<JsonObject> DoReceive() = 0;
25 void Close();
26 virtual void DoClose() = 0;
27 Log* GetLog() const { return log; }
28 virtual const std::string& GetActor() const = 0;
29 bool ServerAlive() const { return serverAlive; }
30 void SetServerAlive(bool serverAlive_);
31 void SetServer(BuildServer* server_) { server = server_; }
32 virtual Host* GetHost() const = 0;
33 private:
34 Log* log;
35 BuildServer* server;
36 bool serverAlive;
37 };
38
39 } }
40
41 #endif // CMAJOR_BUILD_CONNECTION_INCLUDED