reply handling
parent
a2ac6a66d5
commit
8fe0e0c60d
|
@ -21,17 +21,17 @@ type A struct {
|
|||
}
|
||||
|
||||
type WebClient struct {
|
||||
Uuid string
|
||||
MobileConn *websocket.Conn
|
||||
mobileConnMu sync.Mutex
|
||||
MobileCmdIDs []int
|
||||
mobileCmdIDMu sync.Mutex
|
||||
VoiceConn *websocket.Conn
|
||||
voiceConnMu sync.Mutex
|
||||
VoiceCmdIDs []int
|
||||
voiceCmdIDMu sync.Mutex
|
||||
VoiceCMDIDsByBackend []*A
|
||||
voiceCMDIDsByBackendMu sync.Mutex
|
||||
Uuid string
|
||||
MobileConn *websocket.Conn
|
||||
mobileConnMu sync.Mutex
|
||||
MobileCmdIDs []int
|
||||
mobileCmdIDMu sync.Mutex
|
||||
VoiceConn *websocket.Conn
|
||||
voiceConnMu sync.Mutex
|
||||
VoiceCmdIDs []int
|
||||
voiceCmdIDMu sync.Mutex
|
||||
VoiceCMDIDsByBackend map[int]*A // messages from backend to voice, when response from voice then response to target requester
|
||||
//voiceCMDIDsByBackendMu sync.Mutex
|
||||
}
|
||||
|
||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||
|
|
|
@ -77,12 +77,12 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
|||
if status == kraProtocol.StatusGet {
|
||||
webClient := GetWebClientByUuid(playerUuid)
|
||||
|
||||
a := &structs.A{CmdID: 20, CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
||||
|
||||
webClient.VoiceCMDIDsByBackend = append(webClient.VoiceCMDIDsByBackend, a)
|
||||
a := &structs.A{CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
||||
|
||||
cmdID = 20
|
||||
|
||||
webClient.VoiceCMDIDsByBackend[cmdID] = a
|
||||
|
||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusGet, cmdID, cmdNumber, args)
|
||||
} else {
|
||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusSend, 0, cmdNumber, args)
|
||||
|
|
|
@ -45,7 +45,19 @@ func HandleWebMessage(isVoice bool, conn *websocket.Conn, uuid string, msg []byt
|
|||
|
||||
raw = kraProtocol.EncodeJavaMessage(kraProtocol.StatusReply, data.CmdIDFromMinecraftServer, 0, webClient.Uuid, 0, "")
|
||||
|
||||
mcClient.SendBinaryMessage(raw)
|
||||
err = mcClient.SendBinaryMessage(raw)
|
||||
|
||||
if err != nil {
|
||||
logger.Web.Warnln("write:", err)
|
||||
return
|
||||
}
|
||||
|
||||
// remove cmdID from VoiceCMDIDsByBackend list
|
||||
delete(webClient.VoiceCMDIDsByBackend, cmdID)
|
||||
|
||||
// remove cmdID from voiceCmdIDs
|
||||
webClient.RemoveVoiceCmdID(cmdID)
|
||||
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue