2015-05-01 20:59:46 +00:00
|
|
|
package server
|
2015-01-17 01:37:21 +00:00
|
|
|
|
|
|
|
import (
|
2015-05-01 22:20:22 +00:00
|
|
|
"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/gorilla/websocket"
|
2015-01-17 01:37:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type WebSocket struct {
|
|
|
|
conn *websocket.Conn
|
|
|
|
|
2015-01-29 23:38:51 +00:00
|
|
|
Out chan []byte
|
2015-01-17 01:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewWebSocket(ws *websocket.Conn) *WebSocket {
|
|
|
|
return &WebSocket{
|
|
|
|
conn: ws,
|
2015-01-29 23:38:51 +00:00
|
|
|
Out: make(chan []byte, 32),
|
2015-01-17 01:37:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *WebSocket) write() {
|
2015-04-29 21:54:44 +00:00
|
|
|
for {
|
2015-05-01 22:20:22 +00:00
|
|
|
w.conn.WriteMessage(websocket.TextMessage, <-w.Out)
|
2015-01-17 01:37:21 +00:00
|
|
|
}
|
|
|
|
}
|