dispatch/websocket.go
2015-01-17 02:37:21 +01:00

25 lines
324 B
Go

package main
import (
"golang.org/x/net/websocket"
)
type WebSocket struct {
conn *websocket.Conn
In chan []byte
}
func NewWebSocket(ws *websocket.Conn) *WebSocket {
return &WebSocket{
conn: ws,
In: make(chan []byte, 32),
}
}
func (w *WebSocket) write() {
for data := range w.In {
w.conn.Write(data)
}
}