I have a hub class as ChatHub.cs ,i have fetched the data from a view1 but from the same connection made on view1 to hub class ,is it possible to use the same connection in view2 to pass data from ChatHub to view2
Asked
Active
Viewed 894 times
1
-
possible duplicate of [Multiple signalR connections/hubs on your website](http://stackoverflow.com/questions/11764360/multiple-signalr-connections-hubs-on-your-website) – Tharif May 30 '15 at 07:03
1 Answers
0
Yes! It is possible to share updates on different view pages from one single Hub. You can simply assign same ChatHub to both view pages like this:
var chat = $.connection.chatHub;
Then you can send update from first view hub method lets say
Client.All.sendUpdate(name,message);
Where sendUpdate is mentioned in your second view JS
chat.client.sendUpdate =function (name, message) {
$('#discussion').append('<li><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>');
};

Amna
- 603
- 7
- 30
-
I tried doing the same but i am not able to connect to sendUpdate method of view2 , the reason for this may be the connection on this view2 is not fetched by the chatHub class while calling the view2 method as the connection is active from view1 to chatHub – Shashank S Chandel Jun 03 '15 at 05:36