Add cobra, move the server code into its own package
This commit is contained in:
parent
bb729a5c8e
commit
e63c012aad
57 changed files with 6910 additions and 145 deletions
24
server/websocket.go
Normal file
24
server/websocket.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/khlieng/name_pending/Godeps/_workspace/src/golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
type WebSocket struct {
|
||||
conn *websocket.Conn
|
||||
|
||||
Out chan []byte
|
||||
}
|
||||
|
||||
func NewWebSocket(ws *websocket.Conn) *WebSocket {
|
||||
return &WebSocket{
|
||||
conn: ws,
|
||||
Out: make(chan []byte, 32),
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WebSocket) write() {
|
||||
for {
|
||||
w.conn.Write(<-w.Out)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue