Add viewlog controller

This commit is contained in:
chteufleur 2016-12-16 22:05:06 +01:00
parent f0427c6508
commit 4bd4c0417c
1 changed files with 5 additions and 12 deletions

View File

@ -2,16 +2,14 @@ package controllers
import (
"github.com/astaxie/beego"
"github.com/gorilla/websocket"
"github.com/gorilla/websocket"
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
"git.kingpenguin.tk/chteufleur/datahouse.git/watchlog"
"git.kingpenguin.tk/chteufleur/datahouse.git/models/variables"
"git.kingpenguin.tk/chteufleur/datahouse.git/watchlog"
"net/http"
)
type WebSocketController struct {
beego.Controller
}
@ -28,16 +26,12 @@ func (c *WebSocketController) Prepare() {
c.Data["version"] = variables.Version
}
// Get method handles GET requests for WebSocketController.
func (c *WebSocketController) Get() {
c.Data["hostWS"] = "ws://"+c.Ctx.Request.Host+variables.WebSocketLogRoute
c.Data["hostWS"] = "ws://" + c.Ctx.Request.Host + variables.WebSocketLogRoute
c.TplName = "watchlog.tpl"
}
// Join method handles WebSocket requests for WebSocketController.
func (this *WebSocketController) Join() {
// Upgrade from http request to WebSocket.
@ -50,8 +44,7 @@ func (this *WebSocketController) Join() {
return
}
watchlog.ListWebSocket.PushFront(ws)
watchlog.ListWebSocket.PushFront(ws)
// Message receive loop.
for {