From 64488ca5327403483f908c784bbf5f95637a8985 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 29 Dec 2021 12:16:28 +0100 Subject: [PATCH] added func getMinecraftClientByConn --- serverCommunication/minecraft.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/serverCommunication/minecraft.go b/serverCommunication/minecraft.go index c142034..388ab4c 100644 --- a/serverCommunication/minecraft.go +++ b/serverCommunication/minecraft.go @@ -23,6 +23,15 @@ func GetMinecraftClientByName(Name string) *structs.MinecraftClient { return nil } +func GetMinecraftClientByConn(conn *websocket.Conn) *structs.MinecraftClient { + for _, client := range cache.MinecraftClients { + if client.Conn == conn { + return client + } + } + return nil +} + func getMinecraftServerNameByDest(dest int) string { if dest == kraProtocol.DestProxy { return "proxy-1" @@ -77,6 +86,8 @@ func HandleMinecraftMessage(conn *websocket.Conn, status int, cmdID int, dest in if err != nil { logger.Minecraft.Warnln("write:", err) } + } else { // TODO: handle messages -> GameServer-1 to GameServer-2 + logger.Minecraft.Debugln("dest not found", dest) } }