Book Image

SignalR Real-time Application Cookbook

By : Roberto Vespa
Book Image

SignalR Real-time Application Cookbook

By: Roberto Vespa

Overview of this book

Table of Contents (18 chapters)
SignalR Real-time Application Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Broadcasting to all connected clients except the caller


In the previous recipes, we saw a few examples of broadcasting where the sender was always included among the receivers of the message. That was because the APIs we used always included the sender, whether we used the Caller member, the All member, or the Group() method. There are several scenarios though, where it does not make sense to broadcast to the caller; for example, in a live forum application, where it might be enough to broadcast each message to everybody who joined except the sender. That's why SignalR offers the Others member in order to send calls to everybody but the caller. Let's use it.

Getting ready

Before writing the code of this recipe, we need to create a new empty web application, which we'll call Recipe10.

How to do it…

This is a simple Hub. To make it work, we need to perform the following steps:

  1. Add a Hub called EchoHub.

  2. Add the usual OWIN Startup class, which we name Startup, containing the Configuration() method...