debugging

master
Alex 2022-03-19 20:52:56 +01:00
parent 10b3c83ed5
commit 91db91cdab
2 changed files with 14 additions and 94 deletions

View File

@ -25,17 +25,9 @@ type WebClient struct {
Uuid string Uuid string
MobileConn *websocket.Conn MobileConn *websocket.Conn
mobileConnMu sync.Mutex mobileConnMu sync.Mutex
//MobileCmdIDs []int // cache for received cmdIDs
//mobileCmdIDMu sync.Mutex
//MobileCmdIDsByBackend []*A
//mobileCmdIDsByBackendMu sync.Mutex
CurrentMobileSendMessageCmdIDIndexByBackend int CurrentMobileSendMessageCmdIDIndexByBackend int
VoiceConn *websocket.Conn VoiceConn *websocket.Conn
voiceConnMu sync.Mutex voiceConnMu sync.Mutex
//VoiceCmdIDs []int // cache for received cmdIDs
//voiceCmdIDMu sync.Mutex
//VoiceCmdIDsByBackend []*A // messages from backend to voice, when response from voice then response to target requester
//voiceCmdIDsByBackendMu sync.Mutex
CurrentVoiceSendMessageCmdIDIndexByBackend int CurrentVoiceSendMessageCmdIDIndexByBackend int
SendVoiceQueueMessages []*SendQueueMessage SendVoiceQueueMessages []*SendQueueMessage
sendVoiceQueueMessagesMu sync.Mutex sendVoiceQueueMessagesMu sync.Mutex
@ -217,80 +209,6 @@ func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte)
return err return err
} }
/*
func (webClient *WebClient) RemoveVoiceCmdID(cmdID int) {
webClient.voiceCmdIDMu.Lock()
defer webClient.voiceCmdIDMu.Unlock()
newArr, err := removeCmdIDFromList(webClient.VoiceCmdIDs, cmdID)
if err != nil {
logger.WebVoice.Warnln("removeCmdIDFromList:", err)
} else {
webClient.VoiceCmdIDs = newArr
}
}
func (webClient *WebClient) RemoveMobileCmdID(cmdID int) {
webClient.mobileCmdIDMu.Lock()
defer webClient.mobileCmdIDMu.Unlock()
newArr, err := removeCmdIDFromList(webClient.MobileCmdIDs, cmdID)
if err != nil {
logger.WebMobile.Warnln("removeCmdIDFromList:", err)
} else {
webClient.MobileCmdIDs = newArr
}
}
func (webClient *WebClient) RemoveVoiceCmdIDByBackend(cmdID int) {
webClient.voiceCmdIDsByBackendMu.Lock()
defer webClient.voiceCmdIDsByBackendMu.Unlock()
for i, data := range webClient.VoiceCmdIDsByBackend {
if data.WebCmdID == cmdID {
newArr := append(webClient.VoiceCmdIDsByBackend[:i], webClient.VoiceCmdIDsByBackend[i+1:]...)
webClient.VoiceCmdIDsByBackend = newArr
return
}
}
}
func (webClient *WebClient) RemoveMobileCmdIDByBackend(cmdID int) {
webClient.mobileCmdIDsByBackendMu.Lock()
defer webClient.mobileCmdIDsByBackendMu.Unlock()
for i, data := range webClient.MobileCmdIDsByBackend {
if data.WebCmdID == cmdID {
newArr := append(webClient.MobileCmdIDsByBackend[:i], webClient.MobileCmdIDsByBackend[i+1:]...)
webClient.MobileCmdIDsByBackend = newArr
return
}
}
}
func removeCmdIDFromList(arr []int, cmdID int) ([]int, error) {
index := getCmdIDIndexFromList(arr, cmdID)
if index == -1 {
return []int{}, errors.New("index not found")
}
newArr := append(arr[:index], arr[index+1:]...)
return newArr, nil
}
func getCmdIDIndexFromList(arr []int, cmdID int) int {
for i := 0; i < len(arr); i++ {
if arr[i] == cmdID {
return i
}
}
return -1
}
*/
func GenerateWebCmdID(currentIndex int) int { func GenerateWebCmdID(currentIndex int) int {
if currentIndex >= 250 || currentIndex < 10 { if currentIndex >= 250 || currentIndex < 10 {
return 10 return 10

View File

@ -264,6 +264,8 @@ func SendMessageToMinecraftServer(originDest int, originCmdID int, status int, d
return errors.New("mcClient nil") return errors.New("mcClient nil")
} }
logger.Minecraft.Warnln("status is get", status == kraProtocol.StatusGet)
if status == kraProtocol.StatusGet { if status == kraProtocol.StatusGet {
cmdID = mcClient.GenerateMinecraftCmdID() cmdID = mcClient.GenerateMinecraftCmdID()
} }