-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (31 loc) · 1.08 KB
/
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
40
41
42
43
package main
import (
"net/http"
"webrtc-signaling/pkg/logger"
"webrtc-signaling/webchan"
)
func main() {
// logger.InitLog() // linux 上执行这行,log 会写进 syslog,否则就输出到 stdout
logger.SetLogLevel(logger.LOG_INFO)
logger.Info("default log level: %d", logger.GetLogLevel())
server := webchan.NewServer()
server.OnAuth = func(args interface{}) error {
logger.Info("OnAuth")
return nil
}
go server.Loop()
// server.OnConnection = func(c *webchan.Connection, ars interface{}) {
// logger.Info("OnConnection from %s", c.PeerInfo())
// }
// server.OnMessage = func(c *webchan.Connection, message []byte) {
// logger.Info("OnMessage from %s", c.PeerInfo())
// }
// server.OnDisconnection = func(c *webchan.Connection, message string) {
// logger.Info("OnDisconnection from %s", c.PeerInfo())
// }
serveMux := http.NewServeMux()
serveMux.Handle("/", server)
port := "3000"
logger.Info("server listening on: " + port)
http.ListenAndServe(":" + port, serveMux)
}