26 lines
432 B
Go
26 lines
432 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.company.lan/gopkg/melody"
|
|
)
|
|
|
|
func main() {
|
|
m := melody.New()
|
|
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
http.ServeFile(w, r, "index.html")
|
|
})
|
|
|
|
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
|
|
m.HandleRequest(w, r)
|
|
})
|
|
|
|
m.HandleMessage(func(s *melody.Session, msg []byte) {
|
|
m.Broadcast(msg)
|
|
})
|
|
|
|
http.ListenAndServe(":5000", nil)
|
|
}
|