reply handling
parent
570ce95091
commit
c69201ff61
|
@ -14,16 +14,23 @@ type WebClientDb struct {
|
|||
MobileSessionToken string
|
||||
}
|
||||
|
||||
type A struct {
|
||||
CmdIDFromMinecraftServer int
|
||||
DestFromMinecraftServer int
|
||||
}
|
||||
|
||||
type WebClient struct {
|
||||
Uuid string
|
||||
MobileConn *websocket.Conn
|
||||
mobileConnMu sync.Mutex
|
||||
VoiceConn *websocket.Conn
|
||||
voiceConnMu sync.Mutex
|
||||
MobileCmdIDs []int
|
||||
mobileCmdIDMu sync.Mutex
|
||||
VoiceCmdIDs []int
|
||||
voiceCmdIDMu 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 // key: cmdID, value: minecraftServerDest
|
||||
voiceCMDIDsByBackendMu sync.Mutex
|
||||
}
|
||||
|
||||
func (webClient *WebClient) SendBinaryMessage(conn *websocket.Conn, msg []byte) error {
|
||||
|
|
|
@ -21,6 +21,7 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
|||
}
|
||||
|
||||
if status == kraProtocol.StatusReply {
|
||||
// TODO:
|
||||
if isCmdIDInList(mcClient.CmdIDs, cmdID) {
|
||||
mcClient.RemoveCmdID(cmdID)
|
||||
}
|
||||
|
@ -74,9 +75,15 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
|||
}
|
||||
|
||||
if status == kraProtocol.StatusGet {
|
||||
webClient := GetWebClientByUuid(playerUuid)
|
||||
|
||||
cmdID = 20
|
||||
|
||||
webClient.VoiceCMDIDsByBackend[20] = &structs.A{CmdIDFromMinecraftServer: cmdID, DestFromMinecraftServer: 10}
|
||||
|
||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusGet, cmdID, cmdNumber, args)
|
||||
} else {
|
||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusSend, cmdID, cmdNumber, args)
|
||||
raw = kraProtocol.EncodeWebMessage(kraProtocol.StatusSend, 0, cmdNumber, args)
|
||||
}
|
||||
|
||||
if dest == kraProtocol.DestVoice {
|
||||
|
@ -101,7 +108,7 @@ func HandleMinecraftMessage(conn *websocket.Conn, msg []byte) {
|
|||
if status == kraProtocol.StatusGet {
|
||||
raw = kraProtocol.EncodeJavaMessage(kraProtocol.StatusGet, cmdID, dest, playerUuid, cmdNumber, args)
|
||||
} else {
|
||||
raw = kraProtocol.EncodeJavaMessage(kraProtocol.StatusSend, cmdID, dest, playerUuid, cmdNumber, args)
|
||||
raw = kraProtocol.EncodeJavaMessage(kraProtocol.StatusSend, 0, dest, playerUuid, cmdNumber, args)
|
||||
}
|
||||
|
||||
err = client.SendBinaryMessage(raw)
|
||||
|
|
|
@ -34,6 +34,22 @@ func HandleWebMessage(isVoice bool, conn *websocket.Conn, uuid string, msg []byt
|
|||
if status == kraProtocol.StatusReply {
|
||||
// TODO: TODO: handling reply - answering message to target dest (ex. GameServer-1)
|
||||
|
||||
if isVoice {
|
||||
for vCmdID := range webClient.VoiceCMDIDsByBackend {
|
||||
if vCmdID == cmdID {
|
||||
// forward to target dest
|
||||
targetMcServer := webClient.VoiceCMDIDsByBackend[cmdID]
|
||||
|
||||
mcClient := GetMinecraftClientByName(getMinecraftServerNameByDest(targetMcServer.DestFromMinecraftServer))
|
||||
|
||||
raw = kraProtocol.EncodeJavaMessage(kraProtocol.StatusReply, targetMcServer.CmdIDFromMinecraftServer, 0, webClient.Uuid, 0, "")
|
||||
|
||||
mcClient.SendBinaryMessage(raw)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isVoice && isCmdIDInList(webClient.VoiceCmdIDs, cmdID) {
|
||||
webClient.RemoveVoiceCmdID(cmdID)
|
||||
} else if isCmdIDInList(webClient.MobileCmdIDs, cmdID) {
|
||||
|
|
Loading…
Reference in New Issue