-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
73 lines (60 loc) · 2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"./common"
"./crypto"
"./server"
"./server/session"
"./server/ssettings"
)
var (
gConf *common.Configuration
)
func main() {
common.Print("Loading configuration...", common.MTYPE_NORMAL)
if gConf = common.ImportConfiguration(".\\data\\config\\config.json"); gConf == nil {
common.Print("Cannot load configuration file!", common.MTYPE_ERROR)
return
}
common.Print("Loading protocol keyTable...", common.MTYPE_NORMAL)
if err := crypto.ImportKeyTable(".\\data\\crypto\\keyTable"); err != nil {
common.Print("Key table loading failed: "+err.Error(), common.MTYPE_ERROR)
return
}
common.Print("Starting server...", common.MTYPE_NORMAL)
ssettings.Initialize(1024, 10000000, true)
authServer := &server.Server{}
if authServer.Initialize("AUTH1", "127.0.0.1", 10000, server.PROTOCOL_TCP) {
authServer.OnNewClient = server.OnNewClient
authServer.OnClientDeath = server.OnClientDeath
authServer.OnHeartbeat = server.OnHeartbeat
authServer.SetClientCallbacks(
&session.CallbackSet{
BeforePacketSend: server.BeforePacketSend,
OnPacketReceive: server.OnPacketRecv,
OnPacketSent: server.OnPacketSent,
OnDestroy: server.OnDestroy,
OnClientTick: server.OnTick,
})
common.Print("Authorization Server started.", common.MTYPE_NORMAL)
authServer.Start()
}
admServer := &server.Server{}
if admServer.Initialize("ADM1", "127.0.0.1", 10001, server.PROTOCOL_TCP) {
admServer.OnNewClient = server.Adm_OnNewClient
admServer.OnClientDeath = server.Adm_OnClientDeath
admServer.OnHeartbeat = server.Adm_OnHeartbeat
admServer.SetClientCallbacks(
&session.CallbackSet{
BeforePacketSend: server.Adm_BeforePacketSend,
OnPacketReceive: server.Adm_OnPacketRecv,
OnPacketSent: server.Adm_OnPacketSent,
OnDestroy: server.Adm_OnDestroy,
OnClientTick: server.Adm_OnTick,
})
common.Print("Administration Server started.", common.MTYPE_NORMAL)
admServer.Start()
}
for {
}
common.Print("Server stopped.", common.MTYPE_WARNING)
}