xxxxxxxxxx
SignalR is a real-time communication technology for web applications.
It allows bi-directional communication between the server and the client,
enabling applications to push data to clients in real-time. This means that
the server can send updates to the client without the client having to request them.
One example of how SignalR can be used is in a chat application. When a user
sends a message, the server can use SignalR to immediately push the message to
all connected clients. This allows for real-time communication between users
without the need for constant polling of the server for updates.
Another example is a stock ticker application. The server can use SignalR to
push updates to clients whenever new stock information becomes available,
allowing users to see the latest prices in real-time without having to refresh the page.
Overall, SignalR is a powerful tool for building real-time web applications.
It allows for efficient and timely communication between the server and the client,
enabling a more responsive and interactive user experience.
xxxxxxxxxx
$.connection.hub.start().done(function () {
console.log("id : %o", $.connection.hub.id);
});
xxxxxxxxxx
# NOTE: These instructions only work for 64 bit Debian-based
# Linux distributions such as Ubuntu, Mint etc.
# 1. Install our official public software signing key
wget -O- https://updates.signal.org/desktop/apt/keys.asc |\
sudo apt-key add -
# 2. Add our repository to your list of repositories
echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" |\
sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
# 3. Update your package database and install signal
sudo apt update && sudo apt install signal-desktop
xxxxxxxxxx
# NOTE: These instructions only work for 64-bit Debian-based
# Linux distributions such as Ubuntu, Mint etc.
# 1. Install our official public software signing key:
wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
# 2. Add our repository to your list of repositories:
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' |\
sudo tee /etc/apt/sources.list.d/signal-xenial.list
# 3. Update your package database and install Signal:
sudo apt update && sudo apt install signal-desktop
xxxxxxxxxx
connection.onreconnecting(error => {
console.assert(connection.state === signalR.HubConnectionState.Reconnecting);
document.getElementById("messageInput").disabled = true;
const li = document.createElement("li");
li.textContent = `Connection lost due to error "${error}". Reconnecting.`;
document.getElementById("messageList").appendChild(li);
});
หากไคลเอนต์เชื่อมต่อใหม่ได้สำเร็จภายในสี่ครั้งแรกที่พยายามHubConnectionจะเปลี่ยนกลับไปเป็น
Connectedสถานะและเริ่มการonreconnectedเรียกกลับ นี่เป็นโอกาสในการแจ้งให้ผู้ใช้ทราบว่าการ
เชื่อมต่อได้รับการสถาปนาขึ้นใหม่แล้ว
เนื่องจากการเชื่อมต่อดูเหมือนใหม่กับเซิร์ฟเวอร์ การ ติดต่อกลับconnectionIdจะถูกจัดเตรียม
ใหม่onreconnected
xxxxxxxxxx
//within the Startup.cs file
//configure services method
services.AddSignalR();
//Configure method
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<NotifyHub>("/notify");
});