Signalr 除非启动({transport:';longPolling';}),否则信号器组通知在IE9上不起作用
我在IE9上测试了一个简单的信号器MVC4应用程序。应用程序使用组通知:Signalr 除非启动({transport:';longPolling';}),否则信号器组通知在IE9上不起作用,signalr,Signalr,我在IE9上测试了一个简单的信号器MVC4应用程序。应用程序使用组通知: public class Booking { public void BookFlight(String from, String to, string ConnectionId) { var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProgressHub>(); hubContext.Cl
public class Booking
{
public void BookFlight(String from, String to, string ConnectionId)
{
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProgressHub>();
hubContext.Clients.All.addMessage("Started ... " + DateTime.Now.ToString());
string groupName = "Z"; // "g" + ConnectionId;
HttpContext.Current.Session["StartTime"] = DateTime.Now;
// Book first leg
hubContext.Clients.Group(groupName).addMessage(String.Format("Booking flight: {0}-{1} ...", from, to));
Thread.Sleep(2000);
// Book return
hubContext.Clients.Group(groupName).addMessage(String.Format("Booking flight: {0}-{1} ...", to, from));
Thread.Sleep(3000);
// Book car rent
hubContext.Clients.Group(groupName).addMessage(String.Format("Booking car rent: {0}-{1} ...", to, from));
Thread.Sleep(2000);
// Some return value
hubContext.Clients.All.addMessage("Finished ... " + DateTime.Now.ToString());
//hubContext.Clients.Group(groupName).addMessage("Flight booked successfully. Total Time = " + (DateTime.Now - (DateTime)HttpContext.Current.Session["StartTime"]).ToString());
}
}
namespace SignalrProgressDemo.Common
{
public class ProgressHub : Hub
{
public override Task OnConnected()
{
string groupName = "Z";
return Groups.Add(Context.ConnectionId, groupName);
}
...
如客户机代码所示,IE9仅显示发送给所有人的消息,不显示发送给“Z”组的消息
只有当connection.hub以{transport:'longPolling}开头时,它才能正常工作(=接收组消息)
问题/问题
e。测试IE9-不起作用。您在哪里将客户端添加到组“Z”?@halter73-我在原始帖子中添加了将客户端添加到组“Z”的中心代码。
$(function () {
$("#bookButton").click(function () {
$.ajax("/Home/BookFlight?from=tlv&to=fco&connectionId=" + $.connection.hub.id);
});
var progressHub = $.connection.progressHub;
$.connection.hub.logging = true;
progressHub.client.addMessage = function (message) {
$("#msg").html(message);
};
$.connection.hub.start(); //IE9 does NOT work
//$.connection.hub.start({ transport: 'longPolling' }); //IE9 works OK
});