|
|
|||||
Регистрация: Sep 2012
Сообщений: 1
|
Security error 2048
Здравствуйте. Пишу на AS 3 подключение к серверу.
Код подключения package { import flash.display.Sprite; import flash.events.*; import flash.media.Sound; import flash.net.*; import flash.system.Security; import flash.external.ExternalInterface; public class MessengerGateInterface extends Sprite { private var bsocket:Socket; private var host:String; private var port:Number; public function MessengerGateInterface():void { Security.allowDomain("our.domain.com"); Security.allowInsecureDomain("our.domain.com"); Security.loadPolicyFile("http://our.domain.com/crossdomain.xml"); this.bsocket = new Socket(); this.bsocket.addEventListener(Event.CONNECT, this.onConnect); this.bsocket.addEventListener(Event.CLOSE, this.onClose); this.bsocket.addEventListener(ProgressEvent.SOCKET_DATA, this.dataHandler); this.bsocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.securityError); this.bsocket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); this.setSettings("our.domain.com", 4434); this.connect(); ExternalInterface.call("initGate"); } public function securityError(event:SecurityErrorEvent):void { ExternalInterface.call("onSecurityError", event.toString()+" " + Security.REMOTE.toString()); trace("Security error"); } public function setSettings(host:String,port:Number): void { this.host = host; this.port = port; } public function connect(): void { this.bsocket.connect(this.host, this.port); } public function onConnect(event:Event): void { if (this.bsocket.connected) { ExternalInterface.call("successConnection"); trace("success connection"); } } public function onClose(event:Event): void { this.bsocket.close(); ExternalInterface.call("onCloseConnection"); } public function dataHandler(e:ProgressEvent): void { if (bsocket.bytesAvailable>0) { ExternalInterface.call("receiveFromServer",bsocket.readUTFBytes(bsocket.bytesAvailable)); trace("receive data"); } } public function ioErrorHandler(event:IOErrorEvent):void { ExternalInterface.call("errorConnection"); trace("error connection"); } private function init(e:Event = null):void { new MessengerGateInterface(); } } } Сам файл лежит в корне сайта our.domain.com <?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy> <site-control permitted-cross-domain-policies="all"/> <allow-access-from domain="our.domain.com" to-ports="*" secure="false"/> <allow-http-request-headers-from domain="*" headers="*"/> </cross-domain-policy> QString data = QString(clientConnection->readAll()); if(data == "<policy-file-request/>"){ QString answer = QString("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><site-control permitted-cross-domain-policies=\"all\"><allow-access-from domain=\"our.domain.com\" to-ports=\"*\"/><allow-http-request-headers-from domain=\"*\" headers=\"*\"/></cross-domain-policy>"); clientConnection->write(answer.toStdString().c_str()); echo("Send Policy Data"); return; } Цитата:
|
|
|||||
Lorem ipsum
|
Мы анекдоты и ошибки по номерам не запоминаем, хорошо бы привести текст.
__________________
Поймай яблоко 2! |
|
|||||
В том, что сокетам пофиг ваш кроссдоменник. Сокет сервер должен отдавать файл через порт
http://help.adobe.com/ru_RU/ActionSc...0204-7c60.html |
Часовой пояс GMT +4, время: 00:19. |
|
« Предыдущая тема | Следующая тема » |
|
|