From 9d1c8568ce4a3ccf5f2e1b2e88000836e7090070 Mon Sep 17 00:00:00 2001 From: Ryan Peters Date: Wed, 17 Jan 2024 20:40:27 -0500 Subject: [PATCH] fine tuning --- BinaryDad.Coding/Hubs/CodeHub.cs | 2 +- BinaryDad.Coding/wwwroot/js/hub.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/BinaryDad.Coding/Hubs/CodeHub.cs b/BinaryDad.Coding/Hubs/CodeHub.cs index 6728ff5..43e77d3 100644 --- a/BinaryDad.Coding/Hubs/CodeHub.cs +++ b/BinaryDad.Coding/Hubs/CodeHub.cs @@ -30,7 +30,7 @@ namespace BinaryDad.Coding.Hubs { Console.WriteLine($"Sending code from {user}"); - return Clients.All.SendAsync("ReceiveCode", user, index, code); + return Clients.Others.SendAsync("ReceiveCode", user, index, code); } diff --git a/BinaryDad.Coding/wwwroot/js/hub.js b/BinaryDad.Coding/wwwroot/js/hub.js index 0a727f8..42910b9 100644 --- a/BinaryDad.Coding/wwwroot/js/hub.js +++ b/BinaryDad.Coding/wwwroot/js/hub.js @@ -14,6 +14,7 @@ let isTeacher = window.location.hash === '#4ELQcUq7UnFGghAZCVr4Chr9JmtncigfkGu5WSf9'; let isLive = false; + let editorLock = false; let isLiveMode = function () { @@ -73,8 +74,12 @@ if (!isTeacher && isLive) { + editorLock = true; + let editor = ace.edit($editors[index]); + editorLock = false; + editor.session.setValue(code); } }); @@ -100,7 +105,10 @@ let editor = ace.edit(e); editor.session.on('change', function () { - updateCode(editor, i); + + if (!editorLock) { + updateCode(editor, i); + }; }); // send initial code