Book Image

SignalR: Real-time Application Development - Second Edition

By : Einar Ingerbrigsten
Book Image

SignalR: Real-time Application Development - Second Edition

By: Einar Ingerbrigsten

Overview of this book

Table of Contents (19 chapters)
SignalR – Real-time Application Development Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
11
Hosting a Server Using Self-hosted OWIN
Index

Becoming stateful


SignalR brings a lot to the table for abstractions; we've seen so far the abstractions of persistent connections and Hubs. Diving further into Hubs you'll see that there is even more. One of the cool things one can add is a round-tripped state. This is the state that is carried alongside any traffic going from a client to the server. So whenever you call something from the client to the server or the server calls something on the client, any state you have specified will be transferred along with the call being made. This is something that will be really convenient, especially when you have information that is not necessarily relevant for the method you need to call, but something that you might want to have cross cutting any method you call.

A great example of this, which we will use in this chapter, is the current chat room the user is on. Instead of having to maintain the state manually on the client, we can simply add it to the connection and it will round-trip between...