reply handling

master
Alex 2022-01-01 12:52:32 +01:00
parent 4473d24370
commit b42f073212
2 changed files with 27 additions and 14 deletions

View File

@ -21,19 +21,20 @@ type A struct {
}
type WebClient struct {
Uuid string
MobileConn *websocket.Conn
mobileConnMu sync.Mutex
MobileCmdIDs []int
mobileCmdIDMu sync.Mutex
MobileCmdIDsByBackend []*A
mobileCmdIDsByBackendMu sync.Mutex
VoiceConn *websocket.Conn
voiceConnMu sync.Mutex
VoiceCmdIDs []int
voiceCmdIDMu sync.Mutex
VoiceCmdIDsByBackend []*A // messages from backend to voice, when response from voice then response to target requester
voiceCmdIDsByBackendMu sync.Mutex
Uuid string
MobileConn *websocket.Conn
mobileConnMu sync.Mutex
MobileCmdIDs []int
mobileCmdIDMu sync.Mutex
MobileCmdIDsByBackend []*A
mobileCmdIDsByBackendMu sync.Mutex
VoiceConn *websocket.Conn
voiceConnMu sync.Mutex
VoiceCmdIDs []int
voiceCmdIDMu sync.Mutex
VoiceCmdIDsByBackend []*A // messages from backend to voice, when response from voice then response to target requester
voiceCmdIDsByBackendMu sync.Mutex
CurrentCmdIDIndexByBackend int
}
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
@ -119,3 +120,13 @@ func getCmdIDIndexFromList(arr []int, cmdID int) int {
}
return -1
}
func GenerateWebCmdID(currentIndex int) int {
if currentIndex >= 250 || currentIndex < 10 {
return 10
}
currentIndex++
return currentIndex
}

View File

@ -78,7 +78,9 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
if status == kraProtocol.StatusGet {
webClient := GetWebClientByUuid(playerUuid)
webCmdID := 20
webCmdID := structs.GenerateWebCmdID(webClient.CurrentCmdIDIndexByBackend)
logger.Minecraft.Debugln("webCmdID", webCmdID)
a := &structs.A{WebCmdID: webCmdID, CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}