【发布时间】:2012-07-22 15:32:10
【问题描述】:
我正在尝试让 websocket 在我的开发环境中工作:
- Visual Studio 2010
- Windows 7
- 信号 R 0.51
- 最新的 Chrome / Firefox
不幸的是,Javscript 客户端正在使用长轮询。当我在客户端强制使用网络套接字时,我根本无法连接:
$.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?
【问题讨论】: