forwarding handling
parent
ac12707391
commit
897c03192a
|
@ -28,13 +28,14 @@ type WebClient struct {
|
||||||
mobileCmdIDMu sync.Mutex
|
mobileCmdIDMu sync.Mutex
|
||||||
MobileCmdIDsByBackend []*A
|
MobileCmdIDsByBackend []*A
|
||||||
mobileCmdIDsByBackendMu sync.Mutex
|
mobileCmdIDsByBackendMu sync.Mutex
|
||||||
|
CurrentMobileVoiceCmdIDIndexByBackend int
|
||||||
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
|
CurrentVoiceCmdIDIndexByBackend int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||||
|
|
|
@ -21,7 +21,6 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == kraProtocol.StatusReply {
|
if status == kraProtocol.StatusReply {
|
||||||
// TODO:
|
|
||||||
if isCmdIDInList(mcClient.CmdIDs, cmdID) {
|
if isCmdIDInList(mcClient.CmdIDs, cmdID) {
|
||||||
mcClient.RemoveCmdID(cmdID)
|
mcClient.RemoveCmdID(cmdID)
|
||||||
}
|
}
|
||||||
|
@ -31,6 +30,7 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
var raw []byte
|
var raw []byte
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
// queue handling when message already in process
|
||||||
if status == kraProtocol.StatusGet {
|
if status == kraProtocol.StatusGet {
|
||||||
// cmdID already in queue
|
// cmdID already in queue
|
||||||
logger.Minecraft.Debugln("cmdIDList", mcClient.CmdIDs)
|
logger.Minecraft.Debugln("cmdIDList", mcClient.CmdIDs)
|
||||||
|
@ -49,6 +49,7 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
mcClient.CmdIDs = append(mcClient.CmdIDs, cmdID)
|
mcClient.CmdIDs = append(mcClient.CmdIDs, cmdID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dest handling
|
||||||
if dest == kraProtocol.DestBackend {
|
if dest == kraProtocol.DestBackend {
|
||||||
resArgs := minecraftCommandHandler(cmdNumber, playerUuid)
|
resArgs := minecraftCommandHandler(cmdNumber, playerUuid)
|
||||||
|
|
||||||
|
@ -78,9 +79,12 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
if status == kraProtocol.StatusGet {
|
if status == kraProtocol.StatusGet {
|
||||||
webClient := GetWebClientByUuid(playerUuid)
|
webClient := GetWebClientByUuid(playerUuid)
|
||||||
|
|
||||||
webCmdID := structs.GenerateWebCmdID(webClient.CurrentCmdIDIndexByBackend)
|
var webCmdID int
|
||||||
|
|
||||||
webClient.CurrentCmdIDIndexByBackend = webCmdID
|
if dest == kraProtocol.DestVoice {
|
||||||
|
webCmdID = structs.GenerateWebCmdID(webClient.CurrentVoiceCmdIDIndexByBackend)
|
||||||
|
|
||||||
|
webClient.CurrentVoiceCmdIDIndexByBackend = webCmdID
|
||||||
|
|
||||||
logger.Minecraft.Debugln("webCmdID", webCmdID)
|
logger.Minecraft.Debugln("webCmdID", webCmdID)
|
||||||
|
|
||||||
|
@ -89,6 +93,19 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
||||||
webClient.VoiceCmdIDsByBackend = append(webClient.VoiceCmdIDsByBackend, a)
|
webClient.VoiceCmdIDsByBackend = append(webClient.VoiceCmdIDsByBackend, a)
|
||||||
|
|
||||||
logger.Minecraft.Debugln("VoiceCMDIDsByBackend", webClient.VoiceCmdIDsByBackend)
|
logger.Minecraft.Debugln("VoiceCMDIDsByBackend", webClient.VoiceCmdIDsByBackend)
|
||||||
|
} else { // dest mobile
|
||||||
|
webCmdID = structs.GenerateWebCmdID(webClient.CurrentMobileVoiceCmdIDIndexByBackend)
|
||||||
|
|
||||||
|
webClient.CurrentMobileVoiceCmdIDIndexByBackend = webCmdID
|
||||||
|
|
||||||
|
logger.Minecraft.Debugln("webCmdID", webCmdID)
|
||||||
|
|
||||||
|
a := &structs.A{WebCmdID: webCmdID, CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
||||||
|
|
||||||
|
webClient.MobileCmdIDsByBackend = append(webClient.MobileCmdIDsByBackend, a)
|
||||||
|
|
||||||
|
logger.Minecraft.Debugln("MobileCMDIDsByBackend", webClient.MobileCmdIDsByBackend)
|
||||||
|
}
|
||||||
|
|
||||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusGet, webCmdID, cmdNumber, args)
|
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusGet, webCmdID, cmdNumber, args)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue