我正在try 让WebSockets在我的开发环境中工作:
- Visual Studio 2010
- Windows 7
- 信号R0.51
- 最新Chrome/Firefox
不幸的是,Javscript客户端使用的是长轮询.当我在客户端强制使用web套接字时,我根本无法连接:
$.connection.hub.start({ transport: ['webSockets'] })
服务器代码是自托管的,基于示例,如下所示:
static void Main(string[] args)
{
string url = "http://localhost:8081/";
var server = new Server(url);
// Map the default hub url (/signalr)
server.MapHubs();
// Start the server
server.Start();
Console.WriteLine("Server running on {0}", url);
// Keep going until somebody hits 'x'
while (true)
{
ConsoleKeyInfo ki = Console.ReadKey(true);
if (ki.Key == ConsoleKey.X)
{
break;
}
}
}
public class MyHub : Hub
{
public void Send(string message)
{
Clients.addMessage(message);
}
}
我到处找了找,没有找到确切的答案.我是否需要指定一些额外的东西,使用Visual Studio 2012,还是这只适用于Windows 8/IIS 8?