Прочитав много постов отсюда.Я могу решить большую часть проблемы.
но я все еще получаю ошибку метода.Я не уверен, что я сделал не так здесь.
Я довольно новичок с signalR
{"I": "0", "E": "метод чтения" не может быть разрешен. Метод с таким именем не найден. ","T": "в Microsoft.AspNet.SignalR.Hubs.NullMethodDescriptor.b__0 (IHub emptyHub, Object [] emptyParameters) \ r \ n в Microsoft.AspNet.SignalR.Hubs.HubDispatcher.Incoming (контекст IHubIncomingInvokerContext) \ r \ n--- Конец трассировки стека из предыдущего расположения, где было сгенерировано исключение --- \ r \ n в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (Задача) \ r \ n в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (Задача) \ r \ n в Microsoft.AspNet.SignalR.Hubs.HubPipelineModule. <> C__DisplayClass1.d__3.MoveNext () "}
Вот мой код:
Указатель
.DataSource(dataSource => dataSource
.SignalR()
.Events(events => events.Push(@<text>
function(e) {
var notification = $("#notification").data("kendoNotification");
notification.success(e.type);
}
</text>))
.PageSize(10)
.Transport(tr => tr
.Promise("hubStart")
.Hub("hub")
.Client(c => c
.Read("read")
.Create("create")
.Update("update")
.Destroy("destroy"))
.Server(s => s
.Read("read")
.Create("create")
.Update("update")
.Destroy("destroy")))
Hub.cs
открытый класс Custom: Hub {private readonly ICustomService _services;
public OverrideHub(ICustomService services)
{
_services = services;
}
public IEnumerable<Dto> Read(KeyDto ruleKey)
{
return _services.Read(ruleKey);
}
public void Update(Dto dto)
{
_services.Save(dto);
Clients.Others.update(dto);
}
CustomService.cs
public class CustomService : ICustomService
{
private readonly IRepository _repository;
private readonly ICustomerService _customerSrv;
private readonly IUser _currUser;
public V518Service(IRepository repo, ICustomerService customerService, ICustomerService customerSrv)
{
_repository = repo;
_customerSrv = customerService;
_currUser = CurrentActiveUser.User;
}
public IEnumerable<Dto> Read(KeyDto ruleKey) =>
_repository.read(ruleKey);
Startup.cs конфигурация public void (приложение IAppBuilder) {
//create Hub ninject
var unityHubActivator = new MvcHubActivator();
GlobalHost.DependencyResolver.Register(
typeof(IHubActivator),
() => unityHubActivator);
//Show Hub error
var hubConfiguration = new HubConfiguration {EnableDetailedErrors = true};
//App using SignalR
app.MapSignalR(hubConfiguration);
ConfigureAuth(app);
}
public class MvcHubActivator : IHubActivator
{
public IHub Create(HubDescriptor descriptor)
{
return (IHub)DependencyResolver.Current
.GetService(descriptor.HubType);
}
}