package eliom

  1. Overview
  2. Docs
Advanced client/server Web and mobile framework

Install

Dune Dependency

Authors

Maintainers

Sources

10.3.1.tar.gz
md5=a989128ffd2ffd4a74b17233cd0a4b46
sha512=ee76f43609fc33aad96758e9a9698ec517aa92eaaf4575e3e4b43aaa34b3659f0403370d1c8a20c605465802375cbdf7f98a0d086cb3c73e86d19115064f7f15

doc/eliom.server/Eliom_notif/Make/index.html

Module Eliom_notif.MakeSource

Use this functor if you need to customise your notifications with client-specific data (or block notifications for specific clients). This is made to work specifically in a multi-server set-up as well, where In a multi-server set-up notifications might need to be serialised twice, once before broadcasting them to the other servers (without client information present), and then once more to forward them to the clients possibly augmenting it with client-specific data or block for specific clients; see ARG.prepare.

Note: The communication between servers is not implemented in this module. To `plug in' your method of transporting notifications between servers you can override S.notify. See the manual for an example (coming soon).

Parameters

module A : ARG

Signature

Sourcetype identity = A.identity

identity is the type of values used to differentiate one listener from another. Typically it will be a user, but it could also for instance be a chat window.

Sourcetype key = A.key

key is the type of values designating a given resource.

Sourcetype server_notif = A.server_notif

server notification type; Can be different from client_notif.

Sourcetype client_notif = A.client_notif

client notification type; Can be different from server_notif.

Sourceval init : unit -> unit Lwt.t

Initialise the notification module for the current client. This function needs to be called before using most other functions of this module. It isn't called implicitly during module instantiation because it relies on identity data which might not be available yet.

Sourceval deinit : unit -> unit

Deinitialise/deactivate the notification module for the current client.

Sourceval listen : key -> unit

Make client process listen on data whose index is key

Sourceval unlisten : key -> unit

Stop listening on data key

Sourcemodule Ext : sig ... end
Sourceval notify : ?notfor:[ `Me | `Id of identity ] -> key -> server_notif -> unit

Call notify key n to send a notification n to all clients currently listening on data referenced by key.

If ~notfor is `Me, notification will not be sent to the tab currently doing the request (the one which caused the notification to happen). Note that if notify is called with ~notfor:`Me outside of a request it will fail. If it is `Id id it won't be sent to the destination defined by id.

Sourceval client_ev : unit -> (key * client_notif) Eliom_react.Down.t

Returns the client react event.

'a Eliom_react.Down.t = 'a React.E.t on client side.

Map a function on this event to react to notifications from the server. For example:

let%client handle_notification some_stuff ev = ...

let%server something some_stuff = ignore %client (ignore (React.E.map (handle_notification ~%some_stuff) ~%(Notif_module.client_ev ()) ) : unit)

Sourceval clean : unit -> unit

Call clean () to clear the tables from empty data.

OCaml

Innovation. Community. Security.