Skip to content

Instantly share code, notes, and snippets.

@karlitros
Created July 19, 2012 15:27
Show Gist options
  • Save karlitros/3144671 to your computer and use it in GitHub Desktop.
Save karlitros/3144671 to your computer and use it in GitHub Desktop.
Broadcasts the update to all connected clients using SignalR. I've done this within the controller to demonstrate server -> client pushing.
/// <summary>
/// Broadcasts the update to all connected clients. I've done this directly in the controller to
/// demonstrate server -> client pushing, rather than client -> client pushing.
/// </summary>
/// <param name="updateItem">The update item.</param>
internal static void BroadcastUpdate(Update updateItem)
{
// Fetch the hub's context to broadcast
IHubContext context = GlobalHost.ConnectionManager.GetHubContext<LiveUpdate.Hubs.LiveUpdateHub>();
// Call the hub's feedUpdated method with our news / event item.
context.Clients.feedUpdated(updateItem);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment