websockets talk

This commit is contained in:
Barak Michener 2015-02-07 14:22:40 -05:00
parent 8900500b35
commit 429ba99406
2 changed files with 47 additions and 0 deletions

26
page_template.go Normal file
View file

@ -0,0 +1,26 @@
package main
var pageTemplate = `
<html>
<head>
<title>LiveMarkdown</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript">
var ws = new WebSocket("ws://" + location.host + "/ws" + "{{.}}")
ws.onopen = function() {
$("body").Text("wooot")
}
ws.onmessage = function(evt) {
$("body").Text(evt)
}
ws.onclose = function() {
}
</script>
</head>
<body>
</body>
</html>
`