According to Microsoft's tutorial, I send a message in the hub.
public class ChatHub : Hub
{
public async Task SendMessage(string user, string message)
{
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
}
I read the documentation of a third-party chat service provider, Their API is using the http post endpoint to send a message.
POST /rooms/:room_id/messages
This is another provider's documentation, also a http post endpoint.
[POST] /post_comment
I don't understand why they do this, I want to know the advantages and disadvantages of it.
My question is:
Is using http endpoint a better way?
SignalR from microsoft tutorial is pure code, but third-party providers are complete API endpoints with feature SignalR. IMHO they have normal API but in implementation are using websocket with SignalR for real-time messaging.
They have two parts. First is Server side API and second is Client. Server API allow you do any action for change data (eg. create room ..) and Client is responsible for listening changes and update UI.
They have connection to hub for creating websocket hidden in their SDK. Just look QUISCUS Webhooks or EventHandlers. You can write your own API and also you can use SignalR.
Its simple maintainance if you have separated things (Server POST endpoint, Client listen for changes via websocket).