forked from FlowingSPDG/HLAE-Server-GO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.go
28 lines (24 loc) · 895 Bytes
/
command.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
package mirvpgl
const (
nullStr = byte('\x00')
)
// HLAEServerCommand server command types
type HLAEServerCommand string
const (
ServerCommandHello HLAEServerCommand = "hello"
ServerCommandDataStop HLAEServerCommand = "dataStop"
ServerCommandDataStart HLAEServerCommand = "dataStart"
ServerCommandLevelInit HLAEServerCommand = "levelInit"
ServerCommandLevelShutdown HLAEServerCommand = "levelShutdown"
ServerCommandCam HLAEServerCommand = "cam"
ServerCommandGameEvent HLAEServerCommand = "gameEvent"
)
func commandToByteSlice(cmd string) []byte {
length := len("exec") + 1 + len(cmd) + 1 // "exec" + (nullStr) + command + (nullStr)
command := make([]byte, 0, length)
command = append(command, []byte("exec")...)
command = append(command, nullStr)
command = append(command, []byte(cmd)...)
command = append(command, nullStr)
return command
}