Following program is based on the idea given by following post:
http://spmatt.wordpress.com/2012/04/12/harnessing-signalr-in-sharepoint/
Since Sharepoint 2013 is based on .NET 4, no further configuration is required to use the SignlaR
library. I tried to use Microsoft.AspNet.SignalR.Core version 1.0. The item added and item
edited event class was bind to the Project List. So whenever I created a new project item, it will
be automatically trigger the JavaScript in the web part as stated in the post stated above.
The item added event code is defined as follow:
public override void ItemAdded(SPItemEventProperties properties)
{
...
var connectionManager = GlobalHost.ConnectionManager;
var srContext = connectionManager.GetHubContext("messagehub");
srContext.Clients.Add.addMessage();
...
}
The messagehub class is defined as follow:
public class messagehub : Hub {
public void Send(string message)
{
// Call the addMessage method on all clients
Clients.All.addMessage(message);
}
}
The messagehub is saved in the same package. When I added a new item in the project list,
the itemadded event will be triggered. Error comes up at the GetHubContext statement that said
that messagehub could not be resolved.
How could I resolve this issue?
I created a solution + sourcecode on codeplex http://spsignalr.codeplex.com - there is a working example for an EventReceiver, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With