From 597bfe172385abd857f7acc5ee69ffc3e0f69091 Mon Sep 17 00:00:00 2001 From: kerboul Date: Sun, 17 May 2026 19:01:48 +0200 Subject: [PATCH] fix: chat envoie toujours via HTTP, pas Colyseus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Colyseus disconnectait le client si le handler chat n'était pas déployé côté serveur. Le endpoint HTTP /chat/send broadcaste déjà dans les rooms Colyseus, donc le path Colyseus est superflu. Ajout poll immédiat après envoi pour affichage sans délai. Co-Authored-By: Claude Sonnet 4.6 --- game/Assets/Scripts/UI/ChatUI.cs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/game/Assets/Scripts/UI/ChatUI.cs b/game/Assets/Scripts/UI/ChatUI.cs index 8294ecb..cee5ca6 100644 --- a/game/Assets/Scripts/UI/ChatUI.cs +++ b/game/Assets/Scripts/UI/ChatUI.cs @@ -179,18 +179,8 @@ public class ChatUI : MonoBehaviour if (string.IsNullOrEmpty(text) || PlayerName.Length == 0) return; _inputText = ""; _autoScroll = true; - - var nm = NetworkManager.Instance; - if (nm != null && nm.IsConnected) - { - // Fast path: through Colyseus (room broadcasts it back to all players AND saves to ChatManager) - nm.SendChatMessage(text); - } - else - { - // Fallback: direct HTTP (for frontend-only visitors or disconnected state) - StartCoroutine(DoSend(PlayerName, text)); - } + // Always use HTTP — the server endpoint broadcasts to Colyseus rooms anyway + StartCoroutine(DoSend(PlayerName, text)); } // ─── HTTP polling ───────────────────────────────────────────────────── @@ -233,6 +223,9 @@ public class ChatUI : MonoBehaviour req.downloadHandler = new DownloadHandlerBuffer(); req.SetRequestHeader("Content-Type", "application/json"); yield return req.SendWebRequest(); + + // Immediate poll so the message appears right away + StartCoroutine(DoPoll()); } // Called by NetworkManager when a "chat" message arrives via Colyseus