/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // using include guards instead of #pragma once due to compile issues // with MSVC and BUCK #ifndef HERMES_INSPECTOR_MODERN_CONNECTION_H #define HERMES_INSPECTOR_MODERN_CONNECTION_H #include #include #include #include #include #include namespace facebook { namespace hermes { namespace inspector_modern { namespace chrome { /// Connection is a duplex connection between the client and the debugger. class INSPECTOR_EXPORT Connection { public: /// Connection constructor enables the debugger on the provided runtime. This /// should generally called before you start running any JS in the runtime. Connection( std::unique_ptr adapter, const std::string &title, bool waitForDebugger = false); ~Connection(); /// getRuntime returns the underlying runtime being debugged. HermesRuntime &getRuntime(); /// getTitle returns the name of the friendly name of the runtime that's shown /// to users in Nuclide. std::string getTitle() const; /// connect attaches this connection to the runtime's debugger. Requests to /// the debugger sent via send(). Replies and notifications from the debugger /// are sent back to the client via IRemoteConnection::onMessage. bool connect( std::unique_ptr<::facebook::react::jsinspector_modern::IRemoteConnection> remoteConn); /// disconnect disconnects this connection from the runtime's debugger bool disconnect(); /// sendMessage delivers a JSON-encoded Chrome DevTools Protocol request to /// the debugger. void sendMessage(std::string str); private: class Impl; std::unique_ptr impl_; }; } // namespace chrome } // namespace inspector_modern } // namespace hermes } // namespace facebook #endif // HERMES_INSPECTOR_MODERN_CONNECTION_H