MeshLib C++ Docs
Loading...
Searching...
No Matches
MRMCPGatewayMlTransport.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMcp/MRFastmcpp.h"
4
5#pragma warning(push)
6#pragma warning(disable: 4127)
7#pragma warning(disable: 4800)
8#include <httplib.h>
9#pragma warning(pop)
10
11#include <atomic>
12#include <condition_variable>
13#include <mutex>
14#include <string>
15
16namespace MR::McpGateway
17{
18
26class MLClientTransport final : public fastmcpp::client::ITransport
27{
28public:
30 MLClientTransport( const std::string& targetUrl,
31 const std::string& ssePath,
32 const std::string& messagesPath );
34
35 fastmcpp::Json request( const std::string& route, const fastmcpp::Json& payload ) override;
36
37private:
38 struct HostPort { std::string host; int port = 80; };
39 static HostPort parseHostPort( const std::string& url );
40
43 MLClientTransport( const HostPort& hp,
44 const std::string& ssePath,
45 const std::string& messagesPath );
46
47private:
54 httplib::Client httpForSse_;
55 httplib::sse::SSEClient sse_;
56 httplib::Client httpForPost_;
57
58 std::string messagesPath_;
59 mutable std::mutex sessionMutex_;
60 std::condition_variable sessionCv_;
61 std::string sessionId_;
62 std::atomic<int64_t> nextId_{ 1 };
63};
64
65}
fastmcpp::Json request(const std::string &route, const fastmcpp::Json &payload) override
MLClientTransport(const std::string &targetUrl, const std::string &ssePath, const std::string &messagesPath)
Definition MRMCPGatewayBackend.h:10