简体   繁体   English

Flash WebSockets后备和Jetty 8?

[英]Flash WebSockets fallback and Jetty 8?

I found this awesome example: https://github.com/matzew/jetty-websocket , or an HTML5 WebSocket echo server in Jetty, and I love it's simplicity. 我发现了一个很棒的示例: https : //github.com/matzew/jetty-websocket或Jetty中的HTML5 WebSocket回显服务器,我喜欢它的简单性。 However, the web app I am developing will require a bit more cross-browser compatibility, so I tried to use: https://github.com/gimite/web-socket-js/ as a Flash fallback. 但是,我正在开发的Web应用程序将需要更多的跨浏览器兼容性,因此我尝试使用: https : //github.com/gimite/web-socket-js/作为Flash的备用。

The problem: I need to serve some XML file on port 843 for Flash. 问题:我需要在843端口上为Flash提供一些XML文件。 Now I am new to both Flash and Jetty, and would like to figure out how to accomplish this. 现在,我对Flash和Jetty都是陌生的,并且想弄清楚如何实现此目的。 I have used HTML5 WebSockets before in PHP, Python, and Ruby, and I have the echo server working perfectly on my Mac, but now I need to configure Jetty to send the file. 我以前在PHP,Python和Ruby中使用过HTML5 WebSockets,并且我的echo服务器在Mac上可以完美运行,但是现在我需要配置Jetty发送文件。 Any ideas? 有任何想法吗?

I've tried something like that in Java before. 我以前在Java中尝试过类似的方法。 You dont have to send it with Jetty automatically. 您不必与Jetty自动发送。 Open a socket on 843.port from server and listen it with a thread. 从服务器打开843.port上的套接字,并用线程侦听。 Flash will send the policy request as <policy-file-request/> and after port take a message you will check whether it is policy string. Flash将以<policy-file-request/>发送策略请求,并在端口收到一条消息后,您将检查它是否为策略字符串。 Then you should send 那你应该寄

<cross-domain-policy>
     <allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>

as a message thgrough the port back. 作为消息通过端口返回。 After flash takes these response, the handshake between server and flash is provided. 闪存获得这些响应后,将提供服务器与闪存之间的握手。 Response message might be different in different flash version. 在不同的Flash版本中,响应消息可能有所不同。 If application running on for example 8080 port you should set to-ports attribute 8080; 如果应用程序在例如8080端口上运行,则应将to-ports属性设置为8080;否则,将其设置为8080。

<cross-domain-policy>
     <allow-access-from domain="*" to-ports="8080" />
</cross-domain-policy>

when you're connecting from flash you need to respond with an XML policy file. 从Flash连接时,您需要使用XML策略文件进行响应。 To do this you either create your own server(in whatever language you want) that binds on 848 port and respond with that xml or you could try this solution: http://jwebsocket.org/ 为此,您可以创建自己的服务器(以所需的任何语言)绑定到848端口并使用该xml进行响应,或者可以尝试以下解决方案: http : //jwebsocket.org/

Not sure, but I read somewhere that is based on jetty websockets api. 不确定,但我在某处阅读了基于码头websockets api的内容。

Hope this helps you. 希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM