-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
26 lines (24 loc) · 600 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main
import (
"fmt"
"log"
"net/http"
"socket/config"
"socket/model"
"socket/socket"
)
func main() {
//manager := model.CreateManager()
manager, err := model.CreateManagerWithPub(config.REDIS_URL, config.CHANNEL)
if err != nil {
panic(err)
}
go manager.Run()
log.Printf("socket server listen: 0.0.0.0:%s/ws\n", config.SERVER_PORT)
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
socket.ServeWs(manager, w, r)
})
if err := http.ListenAndServe(fmt.Sprintf("0.0.0.0:%s", config.SERVER_PORT), nil); err != nil {
log.Fatal("ListenAndServe: ", err)
}
}