Last active
October 19, 2017 20:49
-
-
Save hkasera/5d2005368e385cf2c95b200aa71b6fbd to your computer and use it in GitHub Desktop.
RPC example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table peers : { A : client, B : channel ( string ) , C : string} | |
PRIMARY KEY A | |
table random : {C : string} | |
sequence seq | |
fun increment a = nextval seq | |
fun main () = | |
src <- source 0; | |
me <- self; | |
ch <- channel; | |
dml (INSERT INTO peers (A, B, C) | |
VALUES ({[me]}, {[ch]}, {["Hi"]})); | |
rows <- queryX (SELECT * FROM peers WHERE peers.A > {[me]} OR peers.A < {[me]}) | |
(fn row => <xml><tr> | |
<td>{[row.Peers.C]}</td> | |
<td> | |
<button value="Update" onclick={fn _ => n <- rpc (increment row.Peers.C); set src n}/> | |
</td> | |
</tr></xml>); | |
return <xml> | |
<head> | |
<title>Hello WebRTC!</title> | |
</head> | |
<body> | |
<h1>Hello WebRTC!</h1> | |
<table border=1> | |
<tr> <th>Client Name</th> <th>Connect</th> <th>Message</th> </tr> | |
{rows} | |
</table> | |
</body> | |
</xml> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
database dbname=test | |
sql peers.sql | |
safeGet Peers/main | |
peers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val main : unit -> transaction page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment