-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (39 loc) · 846 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
40
41
42
43
44
package main
import (
"fmt"
"net"
"os"
"strings"
"tictac/internal/client"
"tictac/internal/envs"
"tictac/internal/server"
"tictac/internal/tictac"
)
func main() {
envs := envs.GetEnvs()
var connection net.Conn
fmt.Printf("Starting as %s\n", envs.Mode)
switch strings.ToLower(envs.Mode) {
case "client":
connection = client.Connect(client.ClientCofig{
IP: envs.ClientIP,
Port: envs.ClientPort,
})
if connection == nil {
fmt.Printf("Failed to create connection\n")
os.Exit(-1)
}
client.Start(connection)
default:
connection = server.Start(server.ServerConfig{
IP: envs.ServerIP,
Port: envs.ServerPort,
})
if connection == nil {
fmt.Printf("Failed to create connection\n")
os.Exit(-1)
}
tictac.Start(tictac.NewLocalPlayer('O'), tictac.NewRemotePlayer('X', connection))
}
return
}