Mercurial > urweb
diff lib/ur/top.ur @ 699:4e260887d8f2
Chat demo
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 05 Apr 2009 11:48:55 -0400 |
parents | 9a2c18dab11d |
children | 5c099b1308ae |
line wrap: on
line diff
--- a/lib/ur/top.ur Sun Apr 05 11:24:55 2009 -0400 +++ b/lib/ur/top.ur Sun Apr 05 11:48:55 2009 -0400 @@ -196,29 +196,3 @@ case e2 of None => (SQL {e1} IS NULL) | Some _ => sql_binary sql_eq e1 (sql_inject e2) - - -functor Broadcast(M : sig type t end) = struct - sequence s - table t : {Id : int, Client : client, Channel : channel M.t} - - 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) -end