开发者

Flash WebSockets fallback and Jetty 8?

开发者 https://www.devze.com 2023-02-18 17:26 出处:网络
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. However, the web app I am developing will require a bi

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. 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 fallbac开发者_StackOverflow中文版k.

The problem: I need to serve some XML file on port 843 for Flash. Now I am new to both Flash and Jetty, and would like to figure out how to accomplish this. 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. Any ideas?


when you're connecting from flash you need to respond with an XML policy file. 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/

Not sure, but I read somewhere that is based on jetty websockets api.

Hope this helps you.


I've tried something like that in Java before. You dont have to send it with Jetty automatically. Open a socket on 843.port from server and listen it with a thread. Flash will send the policy request as <policy-file-request/> and after port take a message you will check whether it is policy string. 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. If application running on for example 8080 port you should set to-ports attribute 8080;

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

精彩评论

暂无评论...
验证码 换一张
取 消