直到最近才开始使用SignalR,我几天前就已经开始工作,现在无法解决出错的问题.
我有我的中心:
[HubName("roleManagementHub")]
public class RoleManagementHub : GenericHub<RoleManagementRole>
{
public RoleManagementHub(ICurrentlyViewingUserService service) : base(service)
{
}
}
Run Code Online (Sandbox Code Playgroud)
这扩展了我创建的通用集线器:
public class GenericHub<TEntity> : Hub where TEntity : class, IBusinessObject<TEntity>
{
private readonly ICurrentlyViewingUserService service;
public GenericHub(ICurrentlyViewingUserService service)
{
this.service = service;
}
public void ImViewing(string id)
{
string colour;
service.AddCurrentlyViewingUser<TEntity>(id, HttpContext.Current.User.Identity.Name, out colour);
Clients.handleImViewingMessage(HttpContext.Current.User.Identity.Name, colour, id);
}
public void ImLeaving(string id)
{
service.RemoveCurrentlyViewingUser<TEntity>(id, HttpContext.Current.User.Identity.Name);
Clients.handleImLeavingMessage(HttpContext.Current.User.Identity.Name, id);
}
public void IHaveEdited(string id, string property, string content)
{
string colour = service.GetCurrentlyViewingUserColour<TEntity>(id, HttpContext.Current.User.Identity.Name); …Run Code Online (Sandbox Code Playgroud)