This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id" : "1000" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.SignalR; | |
namespace viewer.Hubs | |
{ | |
public class GridEventsHub: Hub | |
{ | |
public GridEventsHub() | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This method gets called by the runtime. Use this method to add services to the container. | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | |
// Awwww yeah! | |
services.AddSignalR(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | |
{ | |
// other configuration ... | |
// Add SignalR hub routes | |
app.UseSignalR(routes => | |
{ | |
routes.MapHub<GridEventsHub>("/hubs/gridevents"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace viewer.Models | |
{ | |
public class GridEvent<T> where T: class | |
{ | |
public string Id { get; set;} | |
public string EventType { get; set;} | |
public string Subject {get; set;} | |
public DateTime EventTime { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.IO; | |
using System.Threading.Tasks; | |
using System.Net; | |
using System.Text; | |
using System.Net.Http; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.IO; | |
using System.Threading.Tasks; | |
using System.Net; | |
using System.Text; | |
using System.Net.Http; | |
using Newtonsoft.Json; | |
using Newtonsoft.Json.Linq; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private bool EventTypeSubcriptionValidation | |
=> HttpContext.Request.Headers["aeg-event-type"].FirstOrDefault() == | |
"SubscriptionValidation"; | |
private bool EventTypeNotification | |
=> HttpContext.Request.Headers["aeg-event-type"].FirstOrDefault() == | |
"Notification"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var details = JsonConvert.DeserializeObject<GridEvent<dynamic>>(e.ToString()); | |
await this.HubContext.Clients.All.SendAsync( | |
"gridupdate", | |
details.Id, | |
details.EventType, | |
details.Subject, | |
details.EventTime.ToLongTimeString(), | |
e.ToString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table id="grid-events" class="table table-striped"> | |
<thead> | |
<th> </th> | |
<th>Event Type</th> | |
<th>Subject</th> | |
</thead> | |
<tbody id="grid-event-details"></tbody> | |
</table> | |
<script id="event-template" type="text/x-handlebars-template"> |
OlderNewer