开发者

Problem with policy file for ActionScript 3 XMLSocket

开发者 https://www.devze.com 2023-01-17 13:56 出处:网络
we\'ve developed a tailored server in .NET to host some basic chat/IM functions for our website, and the client is written in Flex (AS3) using XMLSocket.

we've developed a tailored server in .NET to host some basic chat/IM functions for our website, and the client is written in Flex (AS3) using XMLSocket.

Now we have 2 servers, one dedicated to purely sending policy files, and one handling IM/Chat functions.

Problem is, we can see the client connecting, the policy file is sent, but then Flash ignores the policy file and requests it again from our chat/IM server.

Policy file:

<?xml version="1.0" encoding="UTF-8"?>
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="master-only"/>
  <allow-access-from domain="*" to-ports="*" secure="false"/>
</cross-domain-policy>

Policy server:

Server.LogMessage("Policy Server: Serving policy file.");
            TcpListener listener = (TcpListener)ar.AsyncState;
            Socket client = listener.EndAcceptSocke开发者_运维百科t(ar);
            NetworkStream ns = new NetworkStream(client);
            StreamReader sr = new StreamReader(ns);
            StreamWriter sw = new StreamWriter(ns);

            sr.Read();
            //Send policy
            sw.Write(Server.EncodeString(Server.xmlPolicyFile.OuterXml) + "\0");
            sw.Flush();
            ns.Flush();
            //Cleanup
            sw.Close();
            sr.Close();
            ns.Close();
            //Do it again!
            tcl.BeginAcceptSocket(AcceptCallback, tcl);


Cross Domain Policy only works for the server its on... you can't have a server serving up the policy for a different server... what would stop a villain creating a policy for your machine and stealing your data.

You'll need to have the policy served from the correct server.


Thanks Gergor but what I meant is that we opened one server dedicated to sending out policy files and one to handle actual connections (both on the same machine).

Problem was that you need to immediately send the policy file without doing anything else on the policy server.

0

精彩评论

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