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#include <httplib.h>
6
7#include <atomic>
8#include <condition_variable>
9#include <mutex>
10#include <string>
11
12namespace MR::McpGateway
13{
14
22class MLClientTransport final : public fastmcpp::client::ITransport
23{
24public:
26 MLClientTransport( const std::string& targetUrl,
27 const std::string& ssePath,
28 const std::string& messagesPath );
30
31 fastmcpp::Json request( const std::string& route, const fastmcpp::Json& payload ) override;
32
33private:
34 struct HostPort { std::string host; int port = 80; };
35 static HostPort parseHostPort( const std::string& url );
36
39 MLClientTransport( const HostPort& hp,
40 const std::string& ssePath,
41 const std::string& messagesPath );
42
43private:
50 httplib::Client httpForSse_;
51 httplib::sse::SSEClient sse_;
52 httplib::Client httpForPost_;
53
54 std::string messagesPath_;
55 mutable std::mutex sessionMutex_;
56 std::condition_variable sessionCv_;
57 std::string sessionId_;
58 std::atomic<int64_t> nextId_{ 1 };
59};
60
61}
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