Skip to content

Commit

Permalink
ported successfully to echo v2
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoc64 committed Apr 5, 2016
1 parent a605cae commit c17ad5f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
20 changes: 10 additions & 10 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,17 +909,17 @@ var getMapURI = function(addr) {
//var socketUrl = 'ws://' + $location.host() + '/ws'
console.log("run with ws",socketUrl, $websocket)

// var ws = $websocket.$new({
// url: socketUrl,
// reconnect: true,
// enqueue: true,
// })
var ws = $websocket.$new({
url: socketUrl,
reconnect: true,
enqueue: true,
})

// ws.$on('$open', function() {
// console.log('Established socket connection')
// }).$on('$close', function() {
// console.log('Closed socket connection')
// })
ws.$on('$open', function() {
console.log('Established socket connection')
}).$on('$close', function() {
console.log('Closed socket connection')
})

$rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
var acl = toState.acl
Expand Down
9 changes: 7 additions & 2 deletions cmms.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/labstack/echo/middleware"
_ "github.com/lib/pq"
"github.com/steveoc64/godev/echocors"

"github.com/facebookgo/grace/gracehttp"
)

var e *echo.Echo
Expand Down Expand Up @@ -43,8 +45,9 @@ func main() {

_initRoutes()
e.Static("/", "build")
e.File("/", "build/index.html")
// e.File("/", "build/index.html")

// e.Use(fasthttp.WrapHandler(middleware.Logger()))
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.Use(middleware.Gzip())
Expand All @@ -68,7 +71,9 @@ func main() {
if Config.Debug {
log.Printf("... Starting Web Server on port %d", Config.WebPort)
}
e.Run(standard.New(fmt.Sprintf(":%d", Config.WebPort)))
std := standard.New(fmt.Sprintf(":%d", Config.WebPort))
std.SetHandler(e)
gracehttp.Serve(std.Server)
}

func pinger() {
Expand Down
5 changes: 3 additions & 2 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"

"github.com/thoas/stats"
// "gopkg.in/mgutz/dat.v1"
Expand Down Expand Up @@ -118,8 +119,8 @@ func _initRoutes() {

// Add a websocket handler
// e.WebSocket("/ws", webSocket)
// e.Get("/ws", fasthttp.WrapHandler(websocket.Handler(webSocket)))
e.Get("/ws", doNothing)
e.Get("/ws", standard.WrapHandler(websocket.Handler(webSocket)))
// e.Get("/ws", doNothing)
// e.Get("/ws", standard.WrapHandler(websocket.Handler(func(ws *websocket.Conn) {
// for {
// websocket.Message.Send(ws, "Hello, Client!")
Expand Down
2 changes: 2 additions & 0 deletions terminate
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
killall cmms
exit 0

0 comments on commit c17ad5f

Please sign in to comment.