<html>
	<head>
		<script type="text/javascript">
			var webSocket = null;
			var payload = "foo";

			function openSocket(){
				setTimeout(function(){
					webSocket = new WebSocket("ws://localhost:8001/foo/bar", ["p1", "p2"]);
					webSocket.onclose = openSocket;
					webSocket.onmessage = function(event){
						console.log(event.data);
					};
				}, 1000);
			}

			function init(){
				openSocket();
				setInterval(function(){
					webSocket.send(payload);
					payload += payload;
				}, 1000);
			}
		</script>
	</head>
	<body onload="init();">
	</body>
</html>