-
Notifications
You must be signed in to change notification settings - Fork 17
/
main.go
35 lines (27 loc) · 1.23 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
package main
import (
"fmt"
"net/http"
"github.com/metaworking/channeld/examples/unity-mirror-tanks/tankspb"
"github.com/metaworking/channeld/pkg/channeld"
"github.com/metaworking/channeld/pkg/channeldpb"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
if err := channeld.GlobalSettings.ParseFlag(); err != nil {
fmt.Printf("error parsing CLI flag: %v\n", err)
}
channeld.StartProfiling()
channeld.InitLogs()
channeld.InitMetrics()
channeld.InitConnections(channeld.GlobalSettings.ServerFSM, channeld.GlobalSettings.ClientFSM)
channeld.InitChannels()
channeld.RegisterChannelDataType(channeldpb.ChannelType_SUBWORLD, &tankspb.TankGameChannelData{})
channeld.InitSpatialController()
// Setup Prometheus
http.Handle("/metrics", promhttp.Handler())
go http.ListenAndServe(":8080", nil)
go channeld.StartListening(channeldpb.ConnectionType_SERVER, channeld.GlobalSettings.ServerNetwork, channeld.GlobalSettings.ServerAddress)
// FIXME: After all the server connections are established, the client connection should be listened.*/
channeld.StartListening(channeldpb.ConnectionType_CLIENT, channeld.GlobalSettings.ClientNetwork, channeld.GlobalSettings.ClientAddress)
}