SignalR瓦特/网络套接字 [英] SignalR w/ Web Sockets

查看:148
本文介绍了SignalR瓦特/网络套接字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让WebSockets的在我的开发环境中工作:

I am attempting to get websockets working in my dev environment:


  • 的Visual Studio 2010

  • Windows 7中

  • 信号r 0.51

  • 最新的Chrome / Firefox中

不幸的是,Javscript客户端使用长轮询。当我强迫在客户端网络插座我无法连接在所有的:

Unfortunately the Javscript client is using long polling. When I force web-sockets on the client side I can't connect at all:

$.connection.hub.start({ transport: ['webSockets'] })

服务器code是自托管,并根据样本,看起来像:

Server code is self-hosted and based on the sample and looks like:

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?

I've searched around and found nothing definitive. Do I need to specify some extra things, use Visual Studio 2012 or will this only work on Windows 8 / IIS 8?

推荐答案

根据这个答案 http://stackoverflow.com/a /七十零万零九百二十六分之九百一十三万五千三百三十四你会看到SignalR的WebSocket的支持依赖Windows 8 / IIS8 - 答案还指出,在SignalR的页面GitHub的维基页面,但该页面已经不存在

Based on this answer http://stackoverflow.com/a/9135334/700926 you will see that WebSocket support in SignalR relies on Windows 8 / IIS8 - the answer also points to a wiki page at SignalR's github page, however, that page does not exists anymore.

不过,通过在GitHub上克隆维基回购回去了一些修改,你会看到它根据SignalR的GitHub的页面 SignalR.WebSockets 项目的文件,不存在了 - (这或许可以解释为什么维基网站被删除) - 然而,在Wiki页面为 SignalR.WebSockets 修订从今年2月,它指出:

But, by cloning the wiki repo at github and go back some revisions you will see the documentation of the SignalR.WebSockets project which according to SignalR's github page, does not exist anymore - (which might explain why the wiki site is removed) - however, in a revision of the wikipage for SignalR.WebSockets from February this year, it stated that:

借助 SignalR.WebSockets
  包可以被添加到现有的SignalR项目以允许客户端
  使用的WebSocket
  协议。该SignalR
  jQuery的客户端将自动尝试通过WebSockets的连接(如果
  浏览器支持的话),所以没有必要再做修改客户端
  一边的WebSockets添加到您的SignalR基础的应用。

The SignalR.WebSockets package can be added to an existing SignalR project to allow clients to connect using the WebSocket protocol. The SignalR jQuery client will automatically attempt to connect via WebSockets (if the browser supports it) so no changes are necessary on the client side to add WebSockets to your SignalR based application.

SignalR.WebSockets依赖
   Microsoft.WebSockets
  为了侦听来自内部传入的WebSocket连接
  ASP.NET。这个软件包又依赖于新的WebSockets支持
  已添加到ASP.NET 4.5和IIS 8.0。其结果是,该
  SignalR.WebSockets包将仅在Windows 8机器上工作(.NET
  4.5将安装在早期版本的Windows,但Windows 8中的所需的IIS 8.0)。有关如何安装一个Windows的更多信息
  8机(使用开发商preVIEW)见
  这里

SignalR.WebSockets relies on Microsoft.WebSockets in order to listen for incoming WebSocket connections from within ASP.NET. This package in turn depends on the new WebSockets support that was added to ASP.NET 4.5 and IIS 8.0. As a result, the SignalR.WebSockets package will only work on a Windows 8 machine (.NET 4.5 will install on earlier versions of Windows but Windows 8 is required for IIS 8.0). For more information on how to setup a Windows 8 machine (using the developer preview) see here.

我试图寻找比我已经能够在其目前的版本明确规定以上,但据我所知道的,SignalR维基不涉及这个话题更新的信息。

I have tried searching for newer information than what I have been able to provide above, but as far as I can tell, the SignalR wiki does not cover this topic explicitly in its current version.

这篇关于SignalR瓦特/网络套接字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆