reply handling
parent
4473d24370
commit
b42f073212
|
@ -21,19 +21,20 @@ type A struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebClient struct {
|
type WebClient struct {
|
||||||
Uuid string
|
Uuid string
|
||||||
MobileConn *websocket.Conn
|
MobileConn *websocket.Conn
|
||||||
mobileConnMu sync.Mutex
|
mobileConnMu sync.Mutex
|
||||||
MobileCmdIDs []int
|
MobileCmdIDs []int
|
||||||
mobileCmdIDMu sync.Mutex
|
mobileCmdIDMu sync.Mutex
|
||||||
MobileCmdIDsByBackend []*A
|
MobileCmdIDsByBackend []*A
|
||||||
mobileCmdIDsByBackendMu sync.Mutex
|
mobileCmdIDsByBackendMu sync.Mutex
|
||||||
VoiceConn *websocket.Conn
|
VoiceConn *websocket.Conn
|
||||||
voiceConnMu sync.Mutex
|
voiceConnMu sync.Mutex
|
||||||
VoiceCmdIDs []int
|
VoiceCmdIDs []int
|
||||||
voiceCmdIDMu sync.Mutex
|
voiceCmdIDMu sync.Mutex
|
||||||
VoiceCmdIDsByBackend []*A // messages from backend to voice, when response from voice then response to target requester
|
VoiceCmdIDsByBackend []*A // messages from backend to voice, when response from voice then response to target requester
|
||||||
voiceCmdIDsByBackendMu sync.Mutex
|
voiceCmdIDsByBackendMu sync.Mutex
|
||||||
|
CurrentCmdIDIndexByBackend int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||||
|
@ -119,3 +120,13 @@ func getCmdIDIndexFromList(arr []int, cmdID int) int {
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateWebCmdID(currentIndex int) int {
|
||||||
|
if currentIndex >= 250 || currentIndex < 10 {
|
||||||
|
return 10
|
||||||
|
}
|
||||||
|
|
||||||
|
currentIndex++
|
||||||
|
|
||||||
|
return currentIndex
|
||||||
|
}
|
||||||
|
|
|
@ -78,7 +78,9 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
if status == kraProtocol.StatusGet {
|
if status == kraProtocol.StatusGet {
|
||||||
webClient := GetWebClientByUuid(playerUuid)
|
webClient := GetWebClientByUuid(playerUuid)
|
||||||
|
|
||||||
webCmdID := 20
|
webCmdID := structs.GenerateWebCmdID(webClient.CurrentCmdIDIndexByBackend)
|
||||||
|
|
||||||
|
logger.Minecraft.Debugln("webCmdID", webCmdID)
|
||||||
|
|
||||||
a := &structs.A{WebCmdID: webCmdID, CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
a := &structs.A{WebCmdID: webCmdID, CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue