@@ -250,8 +250,20 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
250250 bool IsAlive{ false };
251251 lws_context* WebSocketContext;
252252 lws_protocols* WebSocketProtocols;
253+ int32 Port;
254+
255+ FString WebSocketDebuggerUrl () const
256+ {
257+ return FString::Printf (TEXT (" ws://127.0.0.1:%d" ), Port);
258+ }
259+
260+ FString DevToolsFrontEndUrl () const
261+ {
262+ return FString::Printf (TEXT (" chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:%d" ), Port);
263+ }
253264
254265 FInspector (v8::Platform* platform, int32 InPort, Local<Context> InContext)
266+ : Port(InPort)
255267 {
256268 platform_ = platform;
257269 isolate_ = InContext->GetIsolate ();
@@ -282,7 +294,7 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
282294 auto result = script->Run ();
283295 }
284296
285- UE_LOG (Javascript, Log, TEXT (" open chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost:%d " ), InPort );
297+ UE_LOG (Javascript, Log, TEXT (" open %s " ), * DevToolsFrontEndUrl () );
286298
287299 InstallRelay ();
288300 }
@@ -438,7 +450,52 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
438450 lws_set_timeout (Wsi, NO_PENDING_TIMEOUT, 0 );
439451 }
440452 break ;
453+ case LWS_CALLBACK_HTTP:
454+ {
455+ auto request = (char *)In;
456+
457+ UE_LOG (Javascript, Log, TEXT (" requested URI:%s" ), UTF8_TO_TCHAR (request));
458+
459+ FString res[][2 ] = {
460+ {
461+ TEXT (" description" ), TEXT (" unreal.js instance" )
462+ },
463+ {
464+ TEXT (" devtoolsFrontendUrl" ), DevToolsFrontEndUrl ()
465+ },
466+ {
467+ TEXT (" type" ), TEXT (" node" )
468+ },
469+ {
470+ TEXT (" id" ), TEXT (" 0" )
471+ },
472+ {
473+ TEXT (" title" ), TEXT (" unreal.js" )
474+ },
475+ {
476+ TEXT (" webSocketDebuggerUrl" ), WebSocketDebuggerUrl ()
477+ }
478+ };
441479
480+ TArray<FString> res2;
481+ for (auto pair : res)
482+ {
483+ res2.Add (FString::Printf (TEXT (" \" %s\" : \" %s\" " ), *pair[0 ], *pair[1 ]));
484+ }
485+
486+ {
487+ auto response = FString (TEXT (" HTTP/1.0 200 OK\r\n Content-Type: application/json; charset=UTF-8\r\n Cache-Control: no-cache\r\n\r\n " ));
488+ FTCHARToUTF8 utf8 (*response);
489+ lws_write_http (Wsi, utf8.Get (), utf8.Length ());
490+ }
491+
492+ {
493+ auto response = FString::Printf (TEXT (" [{%s}]" ), *FString::Join (res2, TEXT (" ," )));
494+ FTCHARToUTF8 utf8 (*response);
495+ lws_write_http (Wsi, utf8.Get (), utf8.Length ());
496+ }
497+ }
498+ break ;
442499 case LWS_CALLBACK_RECEIVE:
443500 {
444501 auto Remaining = lws_remaining_packet_payload (Wsi);
0 commit comments