comparison demo/roundTrip.ur @ 698:9b29ce0babb8

RoundTrip demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 05 Apr 2009 11:24:55 -0400
parents
children 1a317a707d71
comparison
equal deleted inserted replaced
697:755a71c99be5 698:9b29ce0babb8
1 table channels : { Client : client, Channel : channel (string * int * float) }
2
3 fun writeBack v =
4 me <- self;
5 r <- oneRow (SELECT channels.Channel FROM channels WHERE channels.Client = {[me]});
6 send r.Channels.Channel v
7
8 fun main () =
9 me <- self;
10 ch <- channel;
11 dml (INSERT INTO channels (Client, Channel) VALUES ({[me]}, {[ch]}));
12
13 buf <- Buffer.create;
14
15 let
16 fun receiver () =
17 v <- recv ch;
18 Buffer.write buf ("(" ^ v.1 ^ ", " ^ show v.2 ^ ", " ^ show v.3 ^ ")");
19 receiver ()
20
21 fun sender s n f =
22 sleep 2000;
23 writeBack (s, n, f);
24 sender (s ^ "!") (n + 1) (f + 1.23)
25 in
26 return <xml><body onload={spawn (receiver ()); sender "" 0 0.0}>
27 <dyn signal={Buffer.render buf}/>
28 </body></xml>
29 end