1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 16:17:47 +00:00

Ladybird: Add WebSocket server for use by Lagom networking

Hide its use behind the same flag as RequestServer in WebContent.
This commit is contained in:
Andrew Kaster 2023-08-02 18:13:23 -06:00 committed by Andreas Kling
parent dd694215bc
commit 7d7c419ce6
15 changed files with 162 additions and 32 deletions

View file

@ -432,6 +432,7 @@ if (BUILD_LAGOM)
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/ViewImplementation.cpp")
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/WebContentClient.cpp")
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/RequestServerAdapter.cpp")
list(APPEND LIBWEBVIEW_SOURCES "../../Userland/Libraries/LibWebView/WebSocketClientAdapter.cpp")
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebContentServer.ipc WebContent/WebContentServerEndpoint.h)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebContentClient.ipc WebContent/WebContentClientEndpoint.h)
@ -439,6 +440,8 @@ if (BUILD_LAGOM)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebContent/WebDriverServer.ipc WebContent/WebDriverServerEndpoint.h)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/RequestClient.ipc RequestServer/RequestClientEndpoint.h)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/RequestServer.ipc RequestServer/RequestServerEndpoint.h)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebSocket/WebSocketClient.ipc WebSocket/WebSocketClientEndpoint.h)
compile_ipc(${SERENITY_PROJECT_ROOT}/Userland/Services/WebSocket/WebSocketServer.ipc WebSocket/WebSocketServerEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentClientEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebContentServerEndpoint.h)
@ -446,6 +449,8 @@ if (BUILD_LAGOM)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebContent/WebDriverServerEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES RequestServer/RequestClientEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES RequestServer/RequestServerEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebSocket/WebSocketClientEndpoint.h)
list(APPEND LIBWEBVIEW_GENERATED_SOURCES WebSocket/WebSocketServerEndpoint.h)
set(GENERATED_SOURCES ${LIBWEBVIEW_GENERATED_SOURCES})
lagom_lib(LibWebView webview

View file

@ -56,6 +56,7 @@ executable("ladybird_executable") {
"SQLServer",
"WebContent",
"WebDriver",
"WebSocket",
]
deps = [
":compile_resource_file",
@ -149,12 +150,14 @@ if (current_os == "mac") {
"SQLServer",
"WebContent",
"WebDriver",
"WebSocket",
]
sources = [
"$root_out_dir/bin/RequestServer",
"$root_out_dir/bin/SQLServer",
"$root_out_dir/bin/WebContent",
"$root_out_dir/bin/WebDriver",
"$root_out_dir/bin/WebSocket",
"$root_out_dir/bin/headless-browser",
"$root_out_dir/bin/ladybird",
]

View file

@ -0,0 +1,21 @@
executable("WebSocket") {
configs += [ "//Ladybird:ladybird_config" ]
include_dirs = [
"//Userland/Libraries",
"//Userland/Services",
]
deps = [
"//AK",
"//Userland/Libraries/LibCore",
"//Userland/Libraries/LibFileSystem",
"//Userland/Libraries/LibIPC",
"//Userland/Libraries/LibMain",
"//Userland/Libraries/LibProtocol",
"//Userland/Libraries/LibTLS",
"//Userland/Libraries/LibWebSocket",
]
sources = [
"//Userland/Services/WebSocket/ConnectionFromClient.cpp",
"main.cpp",
]
}

View file

@ -22,6 +22,28 @@ compiled_action("RequestServerEndpoint") {
]
}
compiled_action("WebSocketClientEndpoint") {
tool = "//Meta/Lagom/Tools/CodeGenerators/IPCCompiler"
inputs = [ "//Userland/Services/WebSocket/WebSocketClient.ipc" ]
outputs = [ "$root_gen_dir/WebSocket/WebSocketClientEndpoint.h" ]
args = [
rebase_path(inputs[0], root_build_dir),
"-o",
rebase_path(outputs[0], root_build_dir),
]
}
compiled_action("WebSocketServerEndpoint") {
tool = "//Meta/Lagom/Tools/CodeGenerators/IPCCompiler"
inputs = [ "//Userland/Services/WebSocket/WebSocketServer.ipc" ]
outputs = [ "$root_gen_dir/WebSocket/WebSocketServerEndpoint.h" ]
args = [
rebase_path(inputs[0], root_build_dir),
"-o",
rebase_path(outputs[0], root_build_dir),
]
}
shared_library("LibProtocol") {
output_name = "protocol"
include_dirs = [
@ -31,6 +53,8 @@ shared_library("LibProtocol") {
deps = [
":RequestClientEndpoint",
":RequestServerEndpoint",
":WebSocketClientEndpoint",
":WebSocketServerEndpoint",
"//AK",
"//Userland/Libraries/LibCore",
"//Userland/Libraries/LibIPC",
@ -38,9 +62,11 @@ shared_library("LibProtocol") {
sources = [
"Request.cpp",
"RequestClient.cpp",
# TODO: Add WebSocket sources + IPC
"WebSocket.cpp",
"WebSocketClient.cpp",
]
sources += get_target_outputs(":RequestClientEndpoint") +
get_target_outputs(":RequestServerEndpoint")
get_target_outputs(":RequestServerEndpoint") +
get_target_outputs(":WebSocketClientEndpoint") +
get_target_outputs(":WebSocketServerEndpoint")
}

View file

@ -71,6 +71,7 @@ shared_library("LibWebView") {
"StylePropertiesModel.cpp",
"ViewImplementation.cpp",
"WebContentClient.cpp",
"WebSocketClientAdapter.cpp",
]
sources += get_target_outputs(":WebContentClientEndpoint") +
get_target_outputs(":WebContentServerEndpoint") +