Created
January 23, 2015 08:06
-
-
Save uzimith/0066e863a0809d4a91ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers | |
import ( | |
"fmt" | |
"code.google.com/p/go.net/websocket" | |
"github.com/revel/revel" | |
) | |
type App struct { | |
*revel.Controller | |
} | |
func (c App) Index() revel.Result { | |
return c.Render() | |
} | |
func (c App) WebSocket(ws *websocket.Conn) revel.Result { | |
fmt.Println(c.Session) | |
c.Session["connected"] = "true" | |
return nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{set . "title" "Home"}} | |
{{template "header.html" .}} | |
<header class="hero-unit" style="background-color:#A9F16C"> | |
<div class="container"> | |
<div class="row"> | |
<div class="hero-text"> | |
<h1>It works!</h1> | |
<p></p> | |
</div> | |
</div> | |
</div> | |
</header> | |
<div class="container"> | |
<div class="row"> | |
<div class="span6"> | |
{{template "flash.html" .}} | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript" charset="utf-8"> | |
var socket = new WebSocket('ws://'+window.location.host + "/ws"); | |
socket.onopen = function(data) { | |
console.log("open") | |
} | |
socket.onclose = function(data) { | |
console.log("close") | |
} | |
socket.onmessage = function(data) { | |
console.log(data) | |
} | |
</script> | |
{{template "footer.html" .}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Routes | |
# This file defines all application routes (Higher priority routes first) | |
# ~~~~ | |
module:testrunner | |
GET / App.Index | |
WS /ws App.WebSocket | |
# Ignore favicon requests | |
GET /favicon.ico 404 | |
# Map static resources from the /app/public folder to the /public path | |
GET /public/*filepath Static.Serve("public") | |
# Catch all | |
* /:controller/:action :controller.:action |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment