Reputation: 3085
The short version of my question
Is it possible to utilize signalR to send notifications based on connection endpoint (use socket connection as bradcast identifier)?
The long one...
2 clients (apps) on same machine connect to asp.net core
NOTIFICATION backend (based on signalR
).
One app broadcasts to all other apps on same machine.
If another app (from same 'family') is launched it recieves the notifications as well. These apps are totally decoupled and are binded based on the machine they ran on.
Since IP address can be same behind network - bind apps using IP address is not an option.
Thank you for time and efforts
Upvotes: 1
Views: 180
Reputation: 121
You can generate a device-specific token and pass it as hub method parameter.
A properly encrypted MAC address would be a choice (I wouldn't recommend passing your MAC address as plaintext as it's extremely dangerous).
After that you can create groups based on these unique device tokens and send messages within groups.
The hub method would be like:
public async Task OnEnterSession(string deviceToken)
{
await Groups.AddToGroupAsync(Context.ConnectionId, deviceToken);
}
And you can send device-oriented message by calling:
await Clients.Group(deviceToken).SendAsync("clientSideServerCallback", args);
I got this idea from Azure Notification Hub Android SDK. I believe your scenario is somehow commensurate with pushing notification to a mobile device.
Upvotes: 1