I have a SignalR Hub with a non-static method that adds creates a new group based on the email address entered in a form:
public class EmailHub : Hub
{
public void AddEmail(string email)
{
base.Groups.Add(base.Context.ConnectionId, email);
}
}
I would like to call this Hub method from my MVC controller. My method currently looks something like this:
public class MyController : Controller
{
public ActionResult AddEmail(string email)
{
var hub = GlobalHost.ConnectionManager.GetHubContext<EmailHub>();
hub.Clients.All.AddEmail(email);
return View();
}
}
However, the code in the controller does not call the hub method. What can I change to be able to invoke the hub method successfully?