I am trying out signalR with a simple blog poster and i am unsure as to what would be best practice in implementing it.
First Solution: Have the client invoke the post method on the server which will in turn either supply the data to the relevant web api or other method of uploading the data. my intention here to use the already open connection.
public class BlogHub : Hub
{
public void Post(string text)
{
//Internal Webapi call / other method of DB Update.
Clients.All.BroadcastPost(text);
}
}
Second Solution: Have the client do a ajax call to a web api which then calls the post method and broadcasts it back to the client.
public void PostPost(string text) //May have to call this method something different...
{
db.posts.add(new PostModel(text));
db.SaveChanges();
Post(string Text);
}
third solution: Another (probably better) method i haven't thought of.
fourth Solution: I'm horribly abusing how signalR should be used.
Thanks in advance!