Mercurial > urweb
view demo/chat.ur @ 1892:907a82a44f01
Add missing inter-library dependencies
This is needed, at least on recent Ubuntu, to fix these linker errors
when compiling any Ur/Web application:
liburweb.so: undefined reference to `lround'
liburweb.so: undefined reference to `ceil'
liburweb.so: undefined reference to `RAND_bytes'
liburweb.so: undefined reference to `DES_fcrypt'
liburweb.so: undefined reference to `SHA256_Init'
liburweb.so: undefined reference to `SHA256_Final'
liburweb.so: undefined reference to `SHA256_Update'
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
src/c/Makefile.am | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
author | Anders Kaseorg <andersk@mit.edu> |
---|---|
date | Thu, 21 Nov 2013 14:32:11 -0500 |
parents | e6bc6bbd7a32 |
children |
line wrap: on
line source
structure Room = Broadcast.Make(struct type t = string end) sequence s table t : { Id : int, Title : string, Room : Room.topic } PRIMARY KEY Id fun chat id () = r <- oneRow (SELECT t.Title, t.Room FROM t WHERE t.Id = {[id]}); ch <- Room.subscribe r.T.Room; newLine <- source ""; buf <- Buffer.create; let fun onload () = let fun listener () = s <- recv ch; Buffer.write buf s; listener () in listener () end fun getRoom () = r <- oneRow (SELECT t.Room FROM t WHERE t.Id = {[id]}); return r.T.Room fun speak line = room <- getRoom (); Room.send room line fun doSpeak () = line <- get newLine; set newLine ""; rpc (speak line) in return <xml><body onload={onload ()}> <h1>{[r.T.Title]}</h1> <button value="Send:" onclick={fn _ => doSpeak ()}/> <ctextbox source={newLine}/> <h2>Messages</h2> <dyn signal={Buffer.render buf}/> </body></xml> end fun list () = queryX' (SELECT * FROM t) (fn r => count <- Room.subscribers r.T.Room; return <xml><tr> <td>{[r.T.Id]}</td> <td>{[r.T.Title]}</td> <td>{[count]}</td> <td><form><submit action={chat r.T.Id} value="Enter"/></form></td> <td><form><submit action={delete r.T.Id} value="Delete"/></form></td> </tr></xml>) and delete id () = dml (DELETE FROM t WHERE Id = {[id]}); main () and main () = let fun create r = id <- nextval s; room <- Room.create; dml (INSERT INTO t (Id, Title, Room) VALUES ({[id]}, {[r.Title]}, {[room]})); main () in ls <- list (); return <xml><body> <h1>Current Channels</h1> <table> <tr> <th>ID</th> <th>Title</th> <th>#Subscribers</th> </tr> {ls} </table> <h1>New Channel</h1> <form> Title: <textbox{#Title}/><br/> <submit action={create}/> </form> </body></xml> end