Imports System.Web
Imports Microsoft.AspNet.SignalR
Namespace SignalRChat
Public Class NotificationHub
Inherits Hub
Public Sub Send(name As String, message As String)
' Call the broadcastMessage method to update clients.
Clients.All.broadcastMessage(name, message)
End Sub
End Class
End Namespace
Imports Microsoft.Owin.Security
Imports Owin
Imports Microsoft.Owin
'add the attribute here
<Assembly: OwinStartup(GetType(SignalRTutorials.Startup))>
Namespace SignalRTutorials
Public Class Startup
Public Sub Configuration(app As IAppBuilder)
'app.MapSignalR()
Dim hubConfiguration = New HubConfiguration()
hubConfiguration.EnableDetailedErrors = True
hubConfiguration.EnableJavaScriptProxies = True
app.MapSignalR("/signalr", hubConfiguration)
End Class End Namespace
var NotificationHub = $.connection.NotificationHub;
NotificationHub.client.refresh = function (stock) {
//Just some tracing purposes
//console.log('Refresh method triggered successfully!');
//console.log(stock);
//Refresh the gridview with latest data
$("#Gridview1").each(function (i) {
if ($(<code></code>this)[0].id == stock.ID) {
//highlight the row that has data changed then slowly fade
$(this).attr('style', 'background-color: yellow;');
$(this).animate({ backgroundColor: 'white' }, 3000);
}
});
};
$.connection.hub.start().done(function () {
//Just to trace whether your browser successfully connected to SignalR hub
console.log('Connected to SignalR hub, connection ID = ' + $.connection.hub.id); })
Dim context = GlobalHost.ConnectionManager.GetHubContext(Of NotificationHub)()
Dim aTimer = New System.Timers.Timer(1000)
aTimer.Interval = 3000
aTimer.Enabled = True
context.Clients.All.refresh()