From 9c7f5cb21a76e09356684bde988f9daf01e9acbf Mon Sep 17 00:00:00 2001 From: Chris Davoren Date: Wed, 10 Jan 2024 17:57:09 +1000 Subject: [PATCH] Removed old SignalR example code. --- TrafficLightsSignalR/Hubs/LightHub.cs | 5 ---- TrafficLightsSignalR/Pages/Index.cshtml | 31 ----------------------- TrafficLightsSignalR/wwwroot/js/lights.js | 10 -------- 3 files changed, 46 deletions(-) diff --git a/TrafficLightsSignalR/Hubs/LightHub.cs b/TrafficLightsSignalR/Hubs/LightHub.cs index b95aa95..2c7329e 100644 --- a/TrafficLightsSignalR/Hubs/LightHub.cs +++ b/TrafficLightsSignalR/Hubs/LightHub.cs @@ -8,11 +8,6 @@ namespace TrafficLightsSignalR.Hubs { private readonly ITrafficLightStateService _stateService = stateService; - public async Task SendMessage(string user, string message) - { - await Clients.All.SendAsync("ReceiveMessage", user, message); - } - public async Task GetServerState(string connectionId) { Debug.WriteLine("ServerBroadcast called..."); diff --git a/TrafficLightsSignalR/Pages/Index.cshtml b/TrafficLightsSignalR/Pages/Index.cshtml index 9ac2524..9069c57 100644 --- a/TrafficLightsSignalR/Pages/Index.cshtml +++ b/TrafficLightsSignalR/Pages/Index.cshtml @@ -33,36 +33,5 @@
- -
-
-
User
-
-
-
-
Message
-
-
-
-
- -
-
-
-
- -
-
-
-
-
-
-
-
-
-
    -
    -
    -
    diff --git a/TrafficLightsSignalR/wwwroot/js/lights.js b/TrafficLightsSignalR/wwwroot/js/lights.js index 3341fea..0cddfe7 100644 --- a/TrafficLightsSignalR/wwwroot/js/lights.js +++ b/TrafficLightsSignalR/wwwroot/js/lights.js @@ -10,15 +10,6 @@ var connection = new signalR.HubConnectionBuilder().withUrl("/lightHub").build() //Disable the send button until connection is established. document.getElementById("sendButton").disabled = true; -connection.on("ReceiveMessage", function (user, message) { - var li = document.createElement("li"); - document.getElementById("messagesList").appendChild(li); - // We can assign user-supplied strings to an element's textContent because it - // is not interpreted as markup. If you're assigning in any other way, you - // should be aware of possible script injection concerns. - li.textContent = `${user} says ${message}`; -}); - connection.on("ReceiveStateUpdate", function (stateData) { console.log("Update pushed."); updateView(stateData); @@ -30,7 +21,6 @@ connection.on("ReceiveServerState", function (stateData) { }); connection.start().then(function () { - document.getElementById("sendButton").disabled = false; connection.invoke("GetServerState", connection.connectionId).catch(function (err) { return console.error(err.toString()); });