[MUSIC]
>> If I need to either send a message specifically to
one browser or to a group of browsers,
that I would be able to do that.
>> That's true, and I have some fantastic slides
from Anthony Chu that I was about
to show you that actually exemplified that.
>> Let's see them.
>> Before I do that though,
let me actually hop into code for one second.
>> Yeah.
>> What I'll do is I'll open up this RotationHub.
This is my RotationHub in that last demo.
There's more code in this demo,
then I'll show you in the end to
end as we build stuff up later demo.
But what I wanted to show you here is essentially,
we're talking about C# here or .NET.
I have this class called a RotationHub,
and it inherits from
a class called Microsoft.AspNetCore.SignalR hub.
This is just like an abstract class.
What it will give you is,
if you see here, you've got clients.
That's essentially the same thing as we go in this.Clients.
Then as you called out,
in the code that I'm probably using, I'm using all.
What that does is that says,
"I want to send a message to all of
the clients that happen to be
connected to me at this point in time."
You might not always want to do that.
In that case, we've got ideas for things like
caller and other clients and that kind of stuff.
But let me show you what that looks like visually.
I think that makes a little bit better idea.
This is a beautiful slide from Anthony Chu.
What this does, I hope
he didn't show you this, when he was on the show earlier.
>> He didn't.
>> He didn't? Good. I'm going to steal his slides.
Essentially, we have all these clients.
These might be all the different clients that want to see
the 3D things spinning in space for, insert reason here.
If I wanted to target all of them,
what I could do is I could say,
Clients.All.sendMessage, whatever method I'm going to fire.
This is what the code used to look like,
and we would just basically send the argument.
You can see here that I'm sending a string.
You can send it pretty much anything that's serializable,
and they'll just serialize it on the wire.
We actually have support.
The default is JSON,
but we also have support for MessagePack,
so if you wanted to go with MessagePack,
it's smaller, more compressed,
probably it transmits faster.
If you wanted to use MessagePack,
you could actually opt for using
the MessagePack serialization provider,
and then it won't serialize your stuff as JSON
anymore. I do want to point that out.
You can send complex objects.
But in this case, you can see I'm doing Clients.All.sendMessage
and then some sort of a parameter.
All the clients light up and they get stuff.
What I can do next is, I can go right here,
and I can say, "I only want to target one user."
Now, this is what's important.
You saw that I had a couple of different browsers open.
Each one of those browsers would be targeting me as a user.
I'm going to be a user, so as long as you
can identify me by my username,
if you were to call this, my phone would light up,
two browsers would light up, etc., etc., etc.
This is a way for you to target one individual user.
If I wanted to, I could target a group.
In this case, if I was presenting in Vegas,
I might want to target
all the people that happen to be in the Vegas group,
and in this case, I would just use.Groups;
put a string in there,
and it would actually go out and target all of those individual,
the people that are in that group.
You do have to add people to groups.
That is something that you would have to do in your own code.
We don't do something like have a list of groups for you.
That's something that whenever you add somebody to a group,
you would probably also want to add a record to a database
saying that that person is in that group, etc., etc.
I do want to point that out.
We don't do all of the work for you,
but we do set it up for you
to basically give you the capability of the signaller.
That's essentially what it is.
It just gives you the ability to touch
a signal between these individual clients.
>> It sounds like that I, as the developer,
get control then over what it is that I want to
identify as a group or how it is that I want to identify users.
If I want to do it based on
an auth principal or maybe based on a location or whatever it is,
that I have that flexibility to
decide how it is that I want to set up
my users and how I want to set up my groups.
>> Yes. That's true.
For example, we'll talk about it a little bit today,
the Azure SignalR service.
Anthony is way better at that topic than myself.
But one of the things that
we talk about with the Azure SignalR service is,
I think each individual instance
can support something like 100,000 concurrent connections,
which is pretty good if you think about it.
If you want to do more than that,
then you have to add instances.
If you would add an instance like in
the east and an instance in the west,
maybe what you do is you group your users,
and you say, "If you connect from the east,
I'm going to put you in that instance.
If you connect from the west, I'm going
to put you in that instance."
That's actually one way if you get into very, very,
very high user account type scenarios,
that's one scenario where you can
actually bifurcate your users and put
them into individual instances of your Azure SignalR service.