From e665b048473ca89774c6ffc7b383e95f640be748 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Fri, 22 Mar 2024 17:52:57 +0100 Subject: [PATCH] dev -> 7.1 --- tutos/7.1/manual/application.wiki | 57 +++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/tutos/7.1/manual/application.wiki b/tutos/7.1/manual/application.wiki index 2080955d..f5139728 100644 --- a/tutos/7.1/manual/application.wiki +++ b/tutos/7.1/manual/application.wiki @@ -535,9 +535,14 @@ let%client init_client () = >> < (* Cf. section "Client side side-effects on the server" *) let _ = [%client (init_client () : unit) ] in @@ -810,8 +815,14 @@ lines are drawn on both windows. Eliom provides multiple ways for the server to send unsolicited data to the client: -* <> are broadcasting channels where +* Module <> + (or <> + if you are using Ocsigen Start) provides a very simple way to send messages to + clients. It's probably the solution you will use most of the times. +* You can use <> instead, as in this example, in the particular case + when you need to broadcast data to all connected clients. Buses are + broadcasting channels where client and server can participate (see also <> in the client API). @@ -850,6 +861,12 @@ opam install ocsigen-toolkit Add package {{{ocsigen-toolkit.server}}} to the {{{libraries}}} section of your {{{dune}}} file, and {{{ocsigen-toolkit.client}}} to the {{{libraries}}} section of your {{{client/dune}}} file. +In {{{Makefile.options}}}, created by Eliom's distillery, add +{{{ocsigen-toolkit.server}}} to the {{{SERVER_PACKAGES}}}: +<> + To create the widget, we replace {{{page}}} by : <> -Replace {{{main_service}}} by: +Replace the registration of {{{main_service}}} by: <> @@ -1007,6 +1024,11 @@ For using Cairo, first, make sure that it is installed (it is available as {{{cairo2}}} via OPAM). Second, add it to the {{{libraries}}} section in your {{{dune}}} file. +Second, add it to the SERVER_PACKAGES in your Makefile.options: +<> + The {{{draw_server}}} function below is the equivalent of the {{{draw}}} function on the server side and the {{{image_string}}} function outputs the PNG image in a string. @@ -1087,14 +1109,21 @@ in {{{init_client}}}: < ctx##drawImage img 0. 0.; Js._false); >> +As we are now using {{{Eliom_content.Html.D}}} in both client and server sections, +we need to open it in a shared section: + +<> + Finally, we can add a new canvas where we would draw a visualisation of the current size of the brush. The complete code of this application can be found [[https://github.com/ocsigen/graffiti/tree/master/simple|here]].