dispatch/websocket.go

25 lines
380 B
Go
Raw Normal View History

2015-01-17 01:37:21 +00:00
package main
import (
2015-03-04 16:38:10 +00:00
"github.com/khlieng/name_pending/Godeps/_workspace/src/golang.org/x/net/websocket"
2015-01-17 01:37:21 +00:00
)
type WebSocket struct {
conn *websocket.Conn
Out chan []byte
2015-01-17 01:37:21 +00:00
}
func NewWebSocket(ws *websocket.Conn) *WebSocket {
return &WebSocket{
conn: ws,
Out: make(chan []byte, 32),
2015-01-17 01:37:21 +00:00
}
}
func (w *WebSocket) write() {
for data := range w.Out {
2015-01-17 01:37:21 +00:00
w.conn.Write(data)
}
}