2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2016-09-09 08:01:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
|
|
|
|
|
|
|
#include <string>
|
2017-02-23 12:32:24 +00:00
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConnection.h"
|
2017-03-25 03:38:52 +00:00
|
|
|
#include "cmPipeConnection.h"
|
2017-07-23 18:31:13 +00:00
|
|
|
#include "cmUVHandlePtr.h"
|
2016-09-09 08:01:44 +00:00
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
class cmServerBase;
|
2016-09-09 08:01:44 +00:00
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
/***
|
|
|
|
* This connection buffer strategy accepts messages in the form of
|
|
|
|
* [== "CMake Server" ==[
|
|
|
|
{
|
|
|
|
... some JSON message ...
|
|
|
|
}
|
|
|
|
]== "CMake Server" ==]
|
|
|
|
* and only passes on the core json; it discards the envelope.
|
|
|
|
*/
|
|
|
|
class cmServerBufferStrategy : public cmConnectionBufferStrategy
|
2016-09-09 08:01:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-25 03:38:52 +00:00
|
|
|
std::string BufferMessage(std::string& rawBuffer) override;
|
2017-07-20 02:23:34 +00:00
|
|
|
std::string BufferOutMessage(const std::string& rawBuffer) const override;
|
2016-09-09 08:01:44 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-25 03:38:52 +00:00
|
|
|
std::string RequestBuffer;
|
2016-09-09 08:01:44 +00:00
|
|
|
};
|
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
/***
|
|
|
|
* Generic connection over std io interfaces -- tty
|
|
|
|
*/
|
2017-02-25 22:06:34 +00:00
|
|
|
class cmStdIoConnection : public cmEventBasedConnection
|
2016-09-09 08:01:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-25 03:38:52 +00:00
|
|
|
cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
|
|
|
|
|
|
|
|
void SetServer(cmServerBase* s) override;
|
|
|
|
|
2017-02-25 22:06:34 +00:00
|
|
|
bool OnConnectionShuttingDown() override;
|
2016-09-09 08:01:44 +00:00
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
bool OnServeStart(std::string* pString) override;
|
2016-09-09 08:01:44 +00:00
|
|
|
|
|
|
|
private:
|
2017-07-23 18:31:13 +00:00
|
|
|
cm::uv_stream_ptr SetupStream(int file_id);
|
|
|
|
cm::uv_stream_ptr ReadStream;
|
2016-09-09 08:01:44 +00:00
|
|
|
};
|
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
/***
|
|
|
|
* These specific connections use the cmake server
|
|
|
|
* buffering strategy.
|
|
|
|
*/
|
|
|
|
class cmServerStdIoConnection : public cmStdIoConnection
|
2016-09-09 08:01:44 +00:00
|
|
|
{
|
|
|
|
public:
|
2017-03-25 03:38:52 +00:00
|
|
|
cmServerStdIoConnection();
|
|
|
|
};
|
2016-09-09 08:01:44 +00:00
|
|
|
|
2017-03-25 03:38:52 +00:00
|
|
|
class cmServerPipeConnection : public cmPipeConnection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmServerPipeConnection(const std::string& name);
|
2016-09-09 08:01:44 +00:00
|
|
|
};
|