SignalR implemented

This commit is contained in:
TypoMustakes
2024-05-09 17:56:16 +02:00
parent 171d640f03
commit 5b0ff9e099
18 changed files with 520 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
<meta charset="UTF-8">
<title>Teams</title>
<link rel="stylesheet" type="text/css" href="../style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/6.0.1/signalr.js"></script>
<script src="maintainerteam.js"></script>
</head>
<body>

View File

@@ -1,5 +1,41 @@
let teams = [];
let connection = null;
getteams();
setupSignalR();
function setupSignalR() {
connection = new signalR.HubConnectionBuilder()
.withUrl("https://localhost:5001/hub")
.configureLogging(signalR.LogLevel.Information)
.build();
connection.on("MaintainerTeamCreated", (user, message) => {
getteams();
});
connection.on("MaintainerTeamDeleted", (user, message) => {
getteams();
});
connection.on("MaintainerTeamUpdated", (user, message) => {
getteams();
});
connection.onclose(async () => {
await start();
});
start();
}
async function start() {
try {
await connection.start();
console.log("SignalR Connected.");
} catch (err) {
console.log(err);
setTimeout(start, 5000);
}
};
async function getteams()
{
@@ -14,6 +50,8 @@ async function getteams()
function display()
{
document.getElementById('saveresult').innerHTML = '';
document.getElementById('forms').innerHTML = '';
document.getElementById('resultarea').innerHTML = '';
teams.forEach(t => {