2016-09-27 15:01:08 -04: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 10:01:44 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-08-25 20:39:02 +02:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
|
|
|
|
|
|
|
#include <string>
|
2017-02-23 07:32:24 -05:00
|
|
|
|
2017-08-25 20:39:02 +02:00
|
|
|
#include "cmConnection.h"
|
2017-03-24 21:38:52 -06:00
|
|
|
#include "cmPipeConnection.h"
|
2017-07-23 12:31:13 -06:00
|
|
|
#include "cmUVHandlePtr.h"
|
2016-09-09 10:01:44 +02:00
|
|
|
|
2017-03-24 21:38:52 -06:00
|
|
|
class cmServerBase;
|
2016-09-09 10:01:44 +02:00
|
|
|
|
2017-03-24 21:38:52 -06: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 10:01:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-03-24 21:38:52 -06:00
|
|
|
std::string BufferMessage(std::string& rawBuffer) override;
|
2017-07-19 20:23:34 -06:00
|
|
|
std::string BufferOutMessage(const std::string& rawBuffer) const override;
|
2016-09-09 10:01:44 +02:00
|
|
|
|
|
|
|
private:
|
2017-03-24 21:38:52 -06:00
|
|
|
std::string RequestBuffer;
|
2016-09-09 10:01:44 +02:00
|
|
|
};
|
|
|
|
|
2017-03-24 21:38:52 -06:00
|
|
|
/***
|
|
|
|
* Generic connection over std io interfaces -- tty
|
|
|
|
*/
|
2017-02-25 15:06:34 -07:00
|
|
|
class cmStdIoConnection : public cmEventBasedConnection
|
2016-09-09 10:01:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-03-24 21:38:52 -06:00
|
|
|
cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
|
|
|
|
|
|
|
|
void SetServer(cmServerBase* s) override;
|
|
|
|
|
2017-02-25 15:06:34 -07:00
|
|
|
bool OnConnectionShuttingDown() override;
|
2016-09-09 10:01:44 +02:00
|
|
|
|
2017-03-24 21:38:52 -06:00
|
|
|
bool OnServeStart(std::string* pString) override;
|
2016-09-09 10:01:44 +02:00
|
|
|
|
|
|
|
private:
|
2017-07-23 12:31:13 -06:00
|
|
|
cm::uv_stream_ptr SetupStream(int file_id);
|
|
|
|
cm::uv_stream_ptr ReadStream;
|
2016-09-09 10:01:44 +02:00
|
|
|
};
|
|
|
|
|
2017-03-24 21:38:52 -06:00
|
|
|
/***
|
|
|
|
* These specific connections use the cmake server
|
|
|
|
* buffering strategy.
|
|
|
|
*/
|
|
|
|
class cmServerStdIoConnection : public cmStdIoConnection
|
2016-09-09 10:01:44 +02:00
|
|
|
{
|
|
|
|
public:
|
2017-03-24 21:38:52 -06:00
|
|
|
cmServerStdIoConnection();
|
|
|
|
};
|
2016-09-09 10:01:44 +02:00
|
|
|
|
2017-03-24 21:38:52 -06:00
|
|
|
class cmServerPipeConnection : public cmPipeConnection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmServerPipeConnection(const std::string& name);
|
2016-09-09 10:01:44 +02:00
|
|
|
};
|