Removed old SignalR example code.

This commit is contained in:
Chris Davoren 2024-01-10 17:57:09 +10:00
parent 112512e877
commit 9c7f5cb21a
3 changed files with 0 additions and 46 deletions

View File

@ -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...");

View File

@ -33,36 +33,5 @@
<div></div>
<div></div>
</div>
<div class="container">
<div class="row p-1">
<div class="col-1">User</div>
<div class="col-5"><input type="text" id="userInput" /></div>
</div>
<div class="row p-1">
<div class="col-1">Message</div>
<div class="col-5"><input type="text" class="w-100" id="messageInput" /></div>
</div>
<div class="row p-1">
<div class="col-6 text-end">
<input type="button" id="sendButton" value="Send Message" />
</div>
</div>
<div class="row p-1">
<div class="col-6 text-end">
<input type="button" id="updateButton" value="Get State" />
</div>
</div>
<div class="row p-1">
<div class="col-6">
<hr />
</div>
</div>
<div class="row p-1">
<div class="col-6">
<ul id="messagesList"></ul>
</div>
</div>
</div>
<script src="~/js/signalr/dist/browser/signalr.js"></script>
<script src="~/js/lights.js"></script>

View File

@ -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());
});