我一直在尝试让Fleck(C# websocket 服务器实现)中的 echo 服务器示例与web-socket-js(用于旧版浏览器的闪存驱动的 websocket)一起工作,并且遇到了问题。
我遇到的第一个问题是从端口 843 上传客户端访问策略。我放弃了,只是在 Fleck 的 WebSocketConnection 读取方法中添加了一些快速而肮脏的代码......
if (body.StartsWith("<policy-file-request/>"))
{
FleckLog.Debug("Reveived Flash Policy File Request");
var policyFile = @"<?xml version=""1.0""?><!DOCTYPE cross-domain-policy SYSTEM ""http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd""><cross-domain-policy><allow-access-from domain=""*"" to-ports=""*""/></cross-domain-policy>";
byte[] bytes = new System.Text.UTF8Encoding().GetBytes(policyFile);
Socket.Stream.Write(bytes, 0, bytes.Length);
Socket.Stream.WriteByte(0);
Socket.Stream.WriteByte(13);
FleckLog.Debug("Flash Policy File Sent");
return;
}
现在它似乎挂了。这是日志...
web-socket-js 日志:
LOG: [FLASH]:[WebSocket] debug enabled
LOG: [FLASH]:[WebSocket] policy file: xmlsocket://localhost:843
LOG: [FLASH]:[WebSocket] connected
LOG: [FLASH]:[WebSocket] request header:
GET / HTTP/1.1
Host: localhost:8181
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: IVcOUW1sZkUxMGFNJ257dA==
Origin: http://localhost:6976
Sec-WebSocket-Version: 13
Cookie:
从 Fleck 回声服务器我得到这个......
12/11/2012 2:38:37 PM [Info] Server started at ws://localhost:8181
12/11/2012 2:38:43 PM [Debug] Client Connected
12/11/2012 2:38:43 PM [Debug] Received:
12/11/2012 2:38:43 PM [Debug] 23 bytes read
12/11/2012 2:38:43 PM [Debug] Received: <policy-file-request/>
12/11/2012 2:38:43 PM [Debug] Reveived Flash Policy File Request
12/11/2012 2:38:43 PM [Debug] Flash Policy File Sent
12/11/2012 2:38:43 PM [Debug] Client Connected
12/11/2012 2:38:43 PM [Debug] Received:
12/11/2012 2:38:43 PM [Debug] 194 bytes read
12/11/2012 2:38:43 PM [Debug] Received: GET / HTTP/1.1
Host: localhost:8181
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dgNDXk5mfWYPbVlnImYDEA==
Origin: http://localhost:6976
Sec-WebSocket-Version: 13
Cookie:
有没有人让这两个库相处?我正在使用 IE 9.0、Flash 11.5.502.110 和 .NET 4.0。此示例与带有 IE 9.0、Flash 11.5.502.110 的 web-socket-ruby/samples/echo_server.rb 完美配合,并且 Fleck 示例回显服务器与 Firefox/Chrome/etc 完美配合...