I'm trying to implement a chat module in an ASP.NET MVC 4 application based on an example over here. Since this one's not using the latest SignalR version (0.5.3), I had to tweak the code to make it work.
Problem is, I couldn't even get the hubConnection to work. I'm encountering a JS error that says:
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'hubConnection'
I'm not sure why there's no hubConnection method. I have the latest jQuery and SignalR libraries, and I just followed the SignalR 0.5.3 release notes here. Here's a snippet of the generated code in my View:
<script src="/Scripts/jquery-1.8.2.js"></script>
<script src="/Scripts/jquery.signalR-0.5.3.js"></script>
<script type="text/javascript" src="/signalr/hubs"></script>
<script type="text/javascript">
$(function () {
var connection = $.hubConnection();
var chatHubClient = connection.createProxy("chatHub");
connection.start(function () {
chatHubClient.join('TEST');
});
});
</script>
I hope someone can point me to the right direction. Thanks.
Invokes a hub method on the server using the specified method name and arguments. On(HubConnection, String, Action) Registers a handler that will be invoked when the hub method with the specified method name is invoked. On(HubConnection, String, Func<Task>)
This error may be seen if the project contains a folder called SignalR, which will interfere with the automatically-created proxy. To avoid this error, do not use a folder called SignalR in your application, or turn automatic proxy generation off.
A SignalR app can scale out based on the number of messages sent, while the Azure SignalR Service scales to handle any number of connections.
I presume you followed the walkthrough that came with 0.5.3's announcement already? http://blogs.msdn.com/b/webdev/archive/2012/08/22/announcing-the-release-of-signalr-0-5-3.aspx
make sure you can open both /Scripts/jquery.signalR-0.5.3.js and /signalr/hubs in a browser.
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