Mercurial > urweb
view demo/broadcast.ur @ 1907:cb57ba73a61d
make uninstall: Uninstall types_cpp.h, urweb_cpp.h
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
Makefile.am | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
author | Anders Kaseorg <andersk@mit.edu> |
---|---|
date | Fri, 22 Nov 2013 09:36:14 -0500 |
parents | 0406e9cccb72 |
children |
line wrap: on
line source
functor Make(M : sig type t end) = struct sequence s table t : {Id : int, Client : client, Channel : channel M.t} PRIMARY KEY (Id, Client) type topic = int val inj : sql_injectable topic = _ val create = nextval s fun subscribe id = cli <- self; ro <- oneOrNoRows (SELECT t.Channel FROM t WHERE t.Id = {[id]} AND t.Client = {[cli]}); case ro of None => ch <- channel; dml (INSERT INTO t (Id, Client, Channel) VALUES ({[id]}, {[cli]}, {[ch]})); return ch | Some r => return r.T.Channel fun send id msg = queryI (SELECT t.Channel FROM t WHERE t.Id = {[id]}) (fn r => Basis.send r.T.Channel msg) fun subscribers id = r <- oneRow (SELECT COUNT( * ) AS N FROM t WHERE t.Id = {[id]}); return r.N end