The problem happened just last week.
The weekend at home according to the online program test.
Hope to go well next week ~ ~
Url:
http://blog.csdn.net/u012210379/article/details/72912056
Package Controllersimport ("Beegows/models" "FMT" "Log" "Time" "Github.com/astaxie/beego"//"Github.com/astaxie/beego /toolbox "" Github.com/gorilla/websocket ") type Mywebsocketcontroller struct {beego. Controller}var upgrader = WebSocket. Upgrader{}func (c *mywebsocketcontroller) Get () {ws, Err: = Upgrader. Upgrade (C.ctx.responsewriter, c.ctx.request, nil) if err! = Nil {log. Fatal (Err)}//defer ws. Close () Clients[ws] = true/*for {time. Sleep (time. Second * 3) Msg: = models. Message{message: "This is the data sent to the page" + Time. Now (). Format ("2006-01-02 15:04:05")}broadcast <-msg}*/for {time. Sleep (time. Second * 3) var msg models. Message//Read in a new message as JSON and map it to a message objecterr: = ws. Readjson (&msg) if err! = Nil {log. Printf ("The page may be disconnected from WS.") Readjson error:%v ", err) Delete (clients, WS) break} else {fmt. PRINTLN ("Receive information back from page feedback", MSG. Message)}broadcast <-msg}}
Integration of Beego and Websocker