Permalink
Browse files

Calling Security.loadPolicyFile() with port 843 if Flash.loadFlashPol…

…icyFile() has not been called.

Renaming WebSocket.loadPolicyFile() to WebSocket.loadFlashPolicyFile().
WebSocket.loadFlashPolicyFile() now expects URL including xmlsocket://.
  • Loading branch information...
1 parent 0d8d903 commit 6640d9d806972ea1720a273d09e8919464bcd131 @gimite gimite committed Jan 11, 2011
Showing with 18 additions and 7 deletions.
  1. BIN WebSocketMain.swf
  2. BIN WebSocketMainInsecure.zip
  3. +14 −3 flash-src/WebSocketMain.as
  4. +4 −4 web_socket.js
View
Binary file not shown.
View
Binary file not shown.
View
@@ -21,6 +21,7 @@ public class WebSocketMain extends Sprite {
private var callerUrl:String;
private var debug:Boolean = false;
+ private var manualPolicyFileLoaded:Boolean = false;
public function WebSocketMain() {
@@ -50,6 +51,9 @@ public class WebSocketMain extends Sprite {
url:String, protocol:String,
proxyHost:String = null, proxyPort:int = 0,
headers:String = null):WebSocket {
+ if (!manualPolicyFileLoaded) {
+ loadDefaultPolicyFile(url);
+ }
return new WebSocket(this, url, protocol, proxyHost, proxyPort, headers);
}
@@ -62,9 +66,16 @@ public class WebSocketMain extends Sprite {
return URLUtil.getServerName(this.callerUrl);
}
- public function loadPolicyFile(url:String):void {
- log("policy file: " + url);
- Security.loadPolicyFile("xmlsocket://" + URLUtil.getServerNameWithPort(url));
+ private function loadDefaultPolicyFile(wsUrl:String):void {
+ var policyUrl:String = "xmlsocket://" + URLUtil.getServerName(wsUrl) + ":843";
+ log("policy file: " + policyUrl);
+ Security.loadPolicyFile(policyUrl);
+ }
+
+ public function loadManualPolicyFile(policyUrl:String):void {
+ log("policy file: " + policyUrl);
+ Security.loadPolicyFile(policyUrl);
+ manualPolicyFileLoaded = true;
}
public function log(message:String):void {
View
@@ -300,10 +300,10 @@
WebSocket.__tasks = [];
- WebSocket.loadPolicyFile = function(url) {
- WebSocket.__addTask(function() {
- WebSocket.__flash.loadPolicyFile(url);
- });
+ WebSocket.loadFlashPolicyFile = function(url) {
+ WebSocket.__addTask(function() {
+ WebSocket.__flash.loadManualPolicyFile(url);
+ });
}
WebSocket.__initialize = function() {

0 comments on commit 6640d9d

Please sign in to comment.