package main
import (
"fmt"
"git.192k.pw/bake/hubsocket"
"golang.org/x/net/websocket"
"net/http"
)
func main() {
hubsocket.Handle("connect", func(ws *websocket.Conn, body string) {
fmt.Printf("%d clients\n", hubsocket.Clients())
hubsocket.Broadcast("connections", hubsocket.Clients())
})
http.Handle("/", hubsocket.Handler())
http.ListenAndServe(":8080", nil)
}
bake / hubsocket Goto Github PK
View Code? Open in Web Editor NEWGolang websocket http-handler with channels and a hub