我在我的应用程序中使用这些库:
using SignalRDemo.Hubs;
using Microsoft.AspNet.SignalR.Hubs;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
现在我必须实现IConnect, IDisconnect
接口。因此,我using SignalR.Hubs;
在 ChatHub 类中添加并添加了一个函数:
public class ChatHub : Hub, IConnected, IDisconnect
{
public Task Connect()
{
//Call the joined method on all connected clients
return Clients.joined(Context.ConnectionId);
}
}
客户端代码:
chatHub.joined = function (connectionId) {
$('#connections').append('<li>Connect: ' + connectionId + '</li>');
}
但是,当我构建解决方案时,它会显示错误。
'Hub' is an ambiguous reference between 'Microsoft.AspNet.SignalR.Hub' and 'SignalR.Hubs.Hub'