【发布时间】:2012-04-03 20:52:03
【问题描述】:
我有两个 swf:
- 应用程序 swf
- 允许使用 rtmfp 复制加载数据的 p2p 客户端 swf 技术(通过 cirrus 服务)
主要思想是在某个域上拥有一个 p2p 加载器,它能够在 p2p 网络中工作,而无需多次请求每个域的权限,例如:
- 应用程序 1 (http://domain1.com/app.swf) |
- 应用程序 2 (http://domain2.com/app.swf) | p2p 数据加载器 (http://domainp2p.com/p2pcli.swf)
- 应用 N (http://domainN.com/app.swf) |
p2p客户端按请求加载二进制数据,我相信内容真的无所谓。
所以,我使用以下类 (app.swf) 加载 p2pclient swf
public class ClientLoader {
// .. some code
public function load(cb:Function, err:Function):void
{
_cb = cb;
_err = err;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onLoaded);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIoError);
loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, _onSecurityError);
// note that context has neither application domain nor security domain
loader.load(new URLRequest(_url), new LoaderContext());
}
private function _onLoaded(e:Event):void
{
trace("Loaded. Connecting to the p2p network...");
_client = e.target.content;
_client.addEventListener(Event.CONNECT, _onClientReady);
_client.connect();
}
private function _onClientReady(e:Event):void
{
_cb(_client);
}
}
}
p2pclient 本身(p2pcli.swf):
public class P2P extends Sprite
{
public function SqP2P() {
Security.allowDomain("*");
}
public function connect():void
{
_connection = new NetConnection();
_connection.addEventListener(NetStatusEvent.NET_STATUS, _netStatus);
_connection.connect(CIRRUS_ADDRESS, CIRRUS_KEY);
// after successful connect this method called
_loadGroup();
}
private method _loadGroup():void
{
var spec:GroupSpecifier = new GroupSpecifier(_name);
spec.serverChannelEnabled = true;
spec.objectReplicationEnabled = true;
_group = new NetGroup(connection, spec.groupspecWithAuthorizations());
_group.addEventListener(NetStatusEvent.NET_STATUS, _netStatus);
}
private function _netStatus(event:NetStatusEvent):void
{
trace("NetStatusEvent:", event.info.code);
}
}
但 Flash Player 似乎忽略了安全会话并尝试保存 app.swf 所属域的弹出设置,但不保存 p2pcli.swf 域。为什么?!
我有完全相同的代码,但是 p2pcli.swf 被替换为 swf,它将数据存储在本地共享对象中,并且所有 domain1-2-N.com 都可以访问它。
有什么想法吗?
我知道,我的英语很烂:(
【问题讨论】:
标签: actionscript-3 rtmfp adobe-cirrus