Posted to tcl by colin at Sat Jul 31 01:48:51 GMT 2010view pretty

websocket {
    domain WebSocket
    url /ws/
    open {
	alert("Opened");
	ws.send("OPEN");
    }
    events {
	alert("got websocket event");
	$('#content').append(e.data + '<br>')
    }
    js {
	$('#message').change(function(){
	    ws.send("MOOP");
	    //ws.send($(this).val());
	    //$(this).val('');
	});
    }
    html {
	<h1>WebSocket Chat</h1>
	<section id="content"></section>
	<input id="message" type="text"/>
    }
    lambda {
	while {1} {
	    set message [rx]
	    tx $message
	}
    }
}