3 #define V8TOOLKIT_DEBUGGING_ACTIVE 5 #include <websocketpp/config/asio_no_tls.hpp> 6 #include <websocketpp/server.hpp> 10 #include <fmt/ostream.h> 13 #include <v8-inspector.h> 17 #include <nlohmann/json.hpp> 173 void sendResponse(
int callId,
174 std::unique_ptr<v8_inspector::StringBuffer> message)
override {
175 Send(message->string());
179 void sendNotification(std::unique_ptr<v8_inspector::StringBuffer> message)
override {
181 Send(message->string());
185 void flushProtocolNotifications()
override {}
188 void Send(
const v8_inspector::StringView &
string);
190 v8::Isolate *isolate;
193 using DebugServerType = websocketpp::server<websocketpp::config::asio>;
194 DebugServerType debug_server;
196 unsigned short port = 0;
198 using WebSocketConnections = std::set<websocketpp::connection_hdl, std::owner_less<websocketpp::connection_hdl>>;
199 WebSocketConnections connections;
204 bool websocket_validation_handler(websocketpp::connection_hdl hdl);
207 void on_open(websocketpp::connection_hdl hdl);
209 void on_close(websocketpp::connection_hdl hdl);
211 void on_message(websocketpp::connection_hdl hdl, DebugServerType::message_ptr msg);
213 void on_http(websocketpp::connection_hdl hdl);
215 std::chrono::time_point<std::chrono::high_resolution_clock> message_received_time = std::chrono::high_resolution_clock::now();
216 std::chrono::time_point<std::chrono::high_resolution_clock> message_sent_time = std::chrono::high_resolution_clock::now();
219 void wait_for_connection(std::chrono::duration<float> sleep_between_polls = std::chrono::duration<float>(0.1f));
275 std::unique_ptr<WebsocketChannel> channel;
276 std::unique_ptr<v8_inspector::V8Inspector> inspector;
277 std::unique_ptr<v8_inspector::V8InspectorSession> session;
279 std::vector<std::string> message_types_handled_by_v8_inspector = {};
288 while (this->paused) {
289 this->channel->run_one();
291 std::cerr << fmt::format(
"exiting runMessageLoopOnPause") << std::endl;
295 std::cerr << fmt::format(
"quitMessageLoopOnPause, setting paused=false") << std::endl;
296 this->paused =
false;
307 static const int kContextGroupId = 1;
311 v8_inspector::V8InspectorSession &
get_session() {
return *this->session;}
312 void reset_session();
virtual void runMessageLoopOnPause(int contextGroupId) override
v8::Local< v8::Context > ensureDefaultContextInGroup(int group_id) override
v8_inspector::V8InspectorSession & get_session()
virtual void quitMessageLoopOnPause() override
std::string get_base_url() const
std::string const & get_frame_id() const
WebsocketChannel & get_channel()