websockets talk
This commit is contained in:
parent
8900500b35
commit
429ba99406
2 changed files with 47 additions and 0 deletions
26
page_template.go
Normal file
26
page_template.go
Normal 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>
|
||||
`
|
||||
Loading…
Add table
Add a link
Reference in a new issue