From the course: Building Real-Time Web Apps with SignalR 2
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
SignalR connection lifetime
From the course: Building Real-Time Web Apps with SignalR 2
SignalR connection lifetime
- [Instructor] Let's talk a bit about connections in SignalR. We need to understand connections so we can account for different scenarios, such as where the server can be reached. We'll start with a basic overview of what a connection is and what it means. When the user lands on your page and connects to a signal or a hub on your server, that's essentially a new connection being created. On the server side, SignalR keeps track of that new connection within the hub. Once that new connection is created messages can then be sent back and forth between the client and server. A connection may reconnect any number of times if there are connectivity issues. And finally, when a connection is ended, it is disconnected. This is usually when the user leaves the page. Let's look at how you can hook into these events on the server side. A hub can implement three different handlers for connection lifetimes. OnConnected is called when a new client connects to the hub. OnReconnected is called when a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.