-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSignalR.txt
More file actions
86 lines (52 loc) · 1.87 KB
/
Copy pathSignalR.txt
File metadata and controls
86 lines (52 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<script src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/8.0.7/signalr.min.js"></script>
<script>
const connection = new signalR.HubConnectionBuilder()
.withUrl("https://localhost:7012/queuehub")
.withAutomaticReconnect()
.build();
window._queueConnection = connection;
const connBadge = document.getElementById("hq-conn-badge");
const connText = document.getElementById("hq-conn-text");
async function startConnection() {
try {
await connection.start();
connBadge.classList.remove("disconnected");
connBadge.classList.add("connected");
connText.textContent = "Baðlandý";
console.log("SignalR Connected");
}
catch (err) {
console.error(err);
connBadge.classList.remove("connected");
connBadge.classList.add("disconnected");
connText.textContent = "Baðlantý Hatasý";
setTimeout(startConnection, 3000);
}
}
connection.on("PatientCalled", function (queueNumber, patientName) {
console.log("PatientCalled Event");
console.log(queueNumber);
console.log(patientName);
document.getElementById("currentQueueNumber")
.textContent = String(queueNumber).padStart(3, '0');
document.getElementById("currentPatientName")
.textContent = patientName;
const card = document.querySelector(".hq-num-box");
card.style.transform = "scale(1.08)";
setTimeout(() => {
card.style.transform = "scale(1)";
}, 400);
});
connection.onreconnecting(() => {
connBadge.classList.remove("connected");
connBadge.classList.add("disconnected");
connText.textContent = "Yeniden Baðlanýyor";
});
connection.onreconnected(() => {
connBadge.classList.remove("disconnected");
connBadge.classList.add("connected");
connText.textContent = "Baðlandý";
});
startConnection();
</script>
-----------------------------------