This commit is contained in:
Peter Harpending
2026-02-09 14:48:47 -08:00
parent cc95fc5829
commit b6436c84ee
3 changed files with 91 additions and 6 deletions
+29
View File
@@ -233,6 +233,7 @@ handle_request(Sock, R = #request{method = M, path = P}, Received) when M =/= un
route(Sock, get, Route, Request, Received) ->
case Route of
<<"/ws/echo">> -> ws_echo(Sock, Request) , Received;
<<"/ws/webrtc">> -> ws_webrtc(Sock, Request) , Received;
<<"/">> -> route_static(Sock, <<"/index.html">>) , Received;
_ -> route_static(Sock, Route) , Received
end;
@@ -279,6 +280,34 @@ respond_static(Sock, not_found) ->
fd_httpd_utils:http_err(Sock, 404).
%% ------------------------------
%% webrtc
%% ------------------------------
ws_webrtc(Sock, Request) ->
try
case qhl_ws:handshake(Request) of
{ok, Response} ->
fd_httpd_utils:respond(Sock, Response),
ws_webrtc_loop(Sock);
Error ->
tell("ws_webrtc: error: ~tp", [Error]),
fd_httpd_utils:http_err(Sock, 400)
end
catch
X:Y:Z ->
tell(error, "CRASH ws_webrtc: ~tp:~tp:~tp", [X, Y, Z]),
fd_httpd_utils:http_err(Sock, 500)
end.
-record(rs,
{ident = username = undefined :: undefined | string(),
peers = undefined :: undefined | [
-type webrtc_state() :: {username
ws_webrtc_loop(
%% ------------------------------
%% echo
%% ------------------------------