SignalR не может прочитать свойство клиента неопределенного
Я пытаюсь добавить SignalR в мой проект (ASPNET MVC 4). Но я могу'заставить его работать.
На изображении ниже вы можете увидеть ошибку I 'м получение. Я'Я прочитал много сообщений от stackoverflow, но ни один из них не решил мою проблему.
Это то, что я сделал до сих пор:
1) Ran Install-Package Microsoft.AspNet.SignalR -Pre
2) Added RouteTable.Routes.MapHubs(); in Global.asax.cs Application_Start()
3) If I go to http://localhost:9096/Gdp.IServer.Web/signalr/hubs I can see the file content
4) Added to Web.Config
5) Created folder Hubs in the root of the MVC application
6) Moved jquery and signalR scripts to /Scripts/lib folder (I'm not using jquery 1.6.4, I'm using the latest)
Это мой Index.cshtml
List of Messages
@section pageScripts
{
}
Это мой файл IServerHub.cs (находится в папке Hubs)
namespace Gdp.IServer.Ui.Web.Hubs
{
using Microsoft.AspNet.SignalR.Hubs;
[HubName("iServerHub")]
public class IServerHub : Hub
{
public void Send(string name, string message)
{
Clients.All.broadcastMessage(name, message);
}
}
}
И это map.js
$(function () {
// Declare a proxy to reference the hub.
var clientServerHub = $.connection.iServerHub;
// Create a function that the hub can call to broadcast messages.
clientServerHub.client.broadcastMessage = function (name, message) {
$('#discussion').append('<strong>' + name + '</strong>: ' + message + '');
};
// Get the user name and store it to prepend to messages.
$('#displayname').val(prompt('Enter your name:', ''));
// Set initial focus to message input box.
$('#message').focus();
// Start the connection.
$.connection.hub.start().done(function () {
$('#sendmessage').click(function () {
// Html encode display name and message.
var encodedName = $('').text($('#displayname').val()).html();
var encodedMsg = $('').text($('#message').val()).html();
// Call the Send method on the hub.
clientServerHub.server.send(encodedName, encodedMsg);
// Clear text box and reset focus for next comment.
$('#message').val('').focus();
});
});
});
DLLЯ вижу ссылки для SignalR:
Microsoft.AspNet.SignalR.CoreMicrosoft.AspNet.SignalR.OwinMicrosoft.AspNet.SignalR.SystemWebЕсть идеи, как заставить это работать? Должен ли я внести какие-либо изменения, потому что сценарии находятся в папке / Script / lib?
ПРИМЕЧАНИЕ, ям следуя найденной инструкцииВот о том, как настроить Windsor Castle, чтобы он работал с SignalR, и, опять же, кажется, что прокси не может быть создан, и я 'Я получаю ту же ошибку:
Cannot read property client of undefined
это означает, что прокси-сервер к концентратору не был создан
Вот как у меня это на сервере
public class IncidentServerHub : Hub
и так в клиенте
var clientServerHub = $.connection.incidentServerHub;
Опять же, я вижу динамически созданный файл здесь:
/GdpSoftware.Server.Web/signalr/hubs
Итак, почему прокси не создан?
Заранее спасибо!!! Гильермо.