move echo from src/examples/ to examples/

This commit is contained in:
Simon Cruanes 2021-12-11 10:02:04 -05:00
parent 89344f46f0
commit c8982c8836
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
5 changed files with 15 additions and 6 deletions

View file

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
exec dune exec "src/examples/echo.exe" -- $@ exec dune exec "examples/echo.exe" -- $@

View file

@ -9,6 +9,12 @@
(modules sse_client) (modules sse_client)
(libraries unix)) (libraries unix))
(executable
(name echo)
(flags :standard -warn-error -a+8)
(modules echo)
(libraries tiny_httpd tiny_httpd_camlzip))
(rule (rule
(targets test_output.txt) (targets test_output.txt)
(deps (:script ./run_test.sh) ./sse_client.exe ./sse_server.exe) (deps (:script ./run_test.sh) ./sse_client.exe ./sse_server.exe)

View file

@ -44,6 +44,14 @@ let () =
Unix.sleepf 0.1; Unix.sleepf 0.1;
done; done;
); );
S.add_route_server_sent_handler server S.Route.(exact "count" @/ int @/ return)
(fun n _req (module EV : S.SERVER_SENT_GENERATOR) ->
for i=0 to n do
EV.send_event ~data:(string_of_int i) ();
Unix.sleepf 0.1;
done;
EV.close();
);
Printf.printf "listening on http://localhost:%d/\n%!" (S.port server); Printf.printf "listening on http://localhost:%d/\n%!" (S.port server);
match S.run server with match S.run server with

View file

@ -1,5 +0,0 @@
(executables
(names echo)
(flags :standard -warn-error -a+8)
(libraries tiny_httpd tiny_httpd_camlzip))