-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
39 lines (28 loc) · 807 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
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
// "Project/websocket/config"
"Project/websocket/web"
"Project/websocket/webconn"
"flag"
"fmt"
"log"
"net/http"
"github.com/julienschmidt/httprouter"
)
// RegisterRouter 注册路由
func RegisterRouter() *httprouter.Router {
router := httprouter.New()
router.GET("/contest-listen/contest/:contestID/user/:uID", web.WsListenHandler)
router.GET("/contest-listen/contest/:contestID/contestOnline", web.ContestOnlineNumHandler)
return router
}
func main() {
port := flag.String("port", "8888", "server port")
flag.Parse()
// config.InitConfig()
go webconn.ListenkillSignal()
serverAddr := fmt.Sprintf("%s:%s", "127.0.0.1", *port)
log.Println("WebSocket Server Listen At:", serverAddr)
r := RegisterRouter()
log.Println(http.ListenAndServe(serverAddr, r))
}